Skip to content
Smart octets buffer.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Export buffer-on-memory-p. Jun 15, 2016
t
.gitignore
.travis.yml
README.markdown
smart-buffer-test.asd
smart-buffer.asd

README.markdown

smart-buffer

Build Status Coverage Status

Smart-buffer provides an output buffer which changes the destination depending on content size.

  • In-memory buffer for small data
  • Temporary files on disk for big data

In-memory buffer is fast to read/write, however, it consumes much memory if the data can be large. On the other hand, files on disk are slower. Smart-buffer would be useful when the buffer must satisfy these two contradicting demands.

Usage

with-smart-buffer returns an in-memory stream or a file stream.

(with-smart-buffer (buffer)
  (write-to-buffer buffer (flex:string-to-octets "foobar")))
;=> #<FLEXI-STREAMS::VECTOR-INPUT-STREAM {100456A9A3}>

(with-smart-buffer (buffer :memory-limit 3)
  (write-to-buffer buffer (flex:string-to-octets "foobar")))
;=> #<SB-SYS:FD-STREAM for "file /private/var/folders/x3/8n07clk15tq3m4y6_yrmjy6c0000gn/T/tmpAR3FSGEY.tmp" {1005D06503}>

Author

Copyright

Copyright (c) 2015 Eitaro Fukamachi (e.arrows@gmail.com)

License

Licensed under the BSD 3-Clause License.

You can’t perform that action at this time.