diff options
author | Piotr Szarmanski | 2023-08-25 19:44:07 +0200 |
---|---|---|
committer | Piotr Szarmanski | 2023-08-25 19:44:07 +0200 |
commit | 2d7036f910bc58c5d791dba560e50ff18adfa70f (patch) | |
tree | 1f2d648e6458bdf97c9b8dd15f70dc6509c0d9ba | |
parent | fed34b8df2b19ba996ef810f44d5666437c90fb7 (diff) |
Remove function-cache, cached-lambda.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | README | 11 | ||||
-rw-r--r-- | eris.asd | 5 | ||||
-rw-r--r-- | src/cache.lisp | 45 | ||||
-rw-r--r-- | src/eris-decode.lisp | 30 | ||||
-rw-r--r-- | src/package.lisp | 2 |
6 files changed, 18 insertions, 77 deletions
@@ -6,6 +6,8 @@ + Removed the :hash-output, as it is rather niche (outputting identical blocks practically does not happen outside of testing) and in the cases where it might be useful, it's simpler to do within the output-function. ++ Removed the :cache-capacity option to the decoder as well as the actual + caching, for the same reasons. + Added a parallel encoder, accessible through ~p/eris-encode~ as well as ~p/{fetch,store}-data~. + ~lparallel~ added as a dependency rather than ~bordeaux-threads~. @@ -5,9 +5,8 @@ the specification. The code is licensed under the LGPLv3 or any later version, unless specified otherwise in a file. -Depends on Alexandria, Serapeum, Ironclad (version 0.58+), function-cache, -trivial-gray-streams, bordeaux-threads, and fiveam for testing. In addition, on -POSIX systems the mmap and osicat libraries are used for the parallel decoder. +Depends on Alexandria, Serapeum, Ironclad (version 0.58+), trivial-gray-streams, +lparallel, and fiveam for testing. The public API is exported by the ERIS package. @@ -27,7 +26,7 @@ The eris-encode (INPUT BLOCK-SIZE OUTPUT-FUNCTION &KEY SECRET HASH-OUTPUT) function can be used to encode a vector, stream or pathname into an ERIS read-capability. -The eris-decode (READ-CAPABILITY FETCH-FUNCTION &KEY (CACHE-CAPACITY 2048)) +The eris-decode (READ-CAPABILITY FETCH-FUNCTION) function can be used to decode an ERIS read-capability. It returns a stream of the class ERIS-DECODE-STREAM: this class implements the Gray streams protocol. @@ -47,8 +46,8 @@ larger or equal to EOF. A high-level API is provided for convenience in backend.lisp. The concept is that a backend object is created, which holds information like output-function, -fetch-function, caching details, block-size, etc. and the {en/de}coding -functions simply take the backend as an argument. +fetch-function, block-size, etc. and the {en/de}coding functions simply take the +backend as an argument. This interface consists of two generic functions: store-data, for encoding data, and fetch-data, for retrieving the contents from a read-capability object. @@ -3,12 +3,11 @@ :author "mail@ykonai.net" :license "LGPLv3 or later" :depends-on ("ironclad" "alexandria" "serapeum" "trivial-gray-streams" - "function-cache" "lparallel" #+unix "osicat" #+unix "mmap") + "lparallel" #+unix "osicat" #+unix "mmap") :components ((:module "src" :serial t - :components ((:file "cache") - (:file "package") + :components ((:file "package") (:file "common") (:file "conditions") (:file "base32") diff --git a/src/cache.lisp b/src/cache.lisp deleted file mode 100644 index d6bce9c..0000000 --- a/src/cache.lisp +++ /dev/null @@ -1,45 +0,0 @@ -;; This is a patch for function-cache, enabling a per-stream cache for -;; eris-decode-stream. - -(in-package :function-cache) - -(defmacro cached-lambda (cache-list lambda-list &body body) - "Creates a cached lambda function with the cache-list - cache-list is a list (&rest CACHE-INIT-ARGS - &key CACHE-CLASS TABLE TIMEOUT SHARED-RESULTS?) - - TABLE - a shared cache-store to use, usually a hash-table, a function that returns - a hashtable, or a symbol whose value is a hash-table - TIMEOUT - how long entries in the cache should be considered valid for - CACHE-CLASS - controls what cache class will be instantiated (uses - default-cache-class if not provided) - SHARED-RESULTS? - do we expect that we are sharing cache space with other things - defaults to t if TABLE is provided - CACHE-INIT-ARGS - any other args that should be passed to the cache - " - (destructuring-bind (&rest cache-args - &key table (shared-results? nil shared-result-input?) - cache-class - &allow-other-keys) - (ensure-list cache-list) - (declare (ignore cache-class)) ;; handled in default-cache-class - (remf cache-args :cache-class) - (remf cache-args :table) - (remf cache-args :shared-results?) - (when (and table (not shared-result-input?)) (setf shared-results? t)) - (let* ((cache-class (default-cache-class (cons nil cache-list) lambda-list)) - (call-list (%call-list-for-lambda-list lambda-list)) - (cache (gensym))) - `(let ((,cache - (make-instance ',cache-class - :body-fn (lambda ,lambda-list - ,@body) - :name nil - :lambda-list ',lambda-list - :shared-results? ,shared-results? - :cached-results ,table - ,@cache-args))) - (lambda ,lambda-list - (cacher ,cache ,call-list)))))) - -(export 'cached-lambda) diff --git a/src/eris-decode.lisp b/src/eris-decode.lisp index df64913..ac458fb 100644 --- a/src/eris-decode.lisp +++ b/src/eris-decode.lisp @@ -209,7 +209,7 @@ it is necessary and sets the position in the buffer to 0." -(defun eris-decode (read-capability fetch-function &key (cache-capacity 2048)) +(defun eris-decode (read-capability fetch-function) "Using the FETCH-FUNCTION, return a stream that decodes the READ-CAPABILITY. This stream implements the Gray streams protocol. @@ -219,32 +219,18 @@ be destructively modified, so you MUST provide a fresh array every time. If a hash-table is used, a (copy-seq) needs to be done on the return value of gethash. -The keyword argument CACHE-CAPACITY indicates the amount of blocks stored in the -cache. It may be NIL to turn off caching entirely. - The conditions ERIS:MISSING-BLOCK, ERIS:PADDING, ERIS:HASH-MISMATCH and ERIS:EOF may be signaled by operations on the stream. Any condition signaled from within FETCH-FUNCTION is not handled." (declare (type read-capability read-capability) - (type function fetch-function) - (type (or integer null) cache-capacity)) + (type function fetch-function)) (with-slots (level block-size root-reference-pair) read-capability - (let* ((get-block (if cache-capacity ;; handle caching - (cached-lambda (:cache-class 'lru-cache - :capacity cache-capacity - :table (make-hash-table :size (1+ cache-capacity) :test #'equalp)) - (rk nonce) - (declare (type octet-vector rk nonce)) - (let ((block (execute-fetch-function fetch-function rk))) - (declare (type octet-vector block)) - (hash-check block rk) - (decrypt-block block rk nonce))) - (lambda (rk nonce) - (declare (type octet-vector rk nonce)) - (let ((block (execute-fetch-function fetch-function rk))) - (declare (type octet-vector block)) - (hash-check block rk) - (decrypt-block block rk nonce))))) + (let* ((get-block (lambda (rk nonce) + (declare (type octet-vector rk nonce)) + (let ((block (execute-fetch-function fetch-function rk))) + (declare (type octet-vector block)) + (hash-check block rk) + (decrypt-block block rk nonce)))) (root (funcall get-block root-reference-pair (make-nonce level)))) ;; "Implementations MUST verify the key appearing in the read capability ;; if level of encoded content is larger than 0." diff --git a/src/package.lisp b/src/package.lisp index 51ca5c7..e516e74 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -15,7 +15,7 @@ (defpackage eris - (:use #:common-lisp #:trivial-gray-streams #:alexandria #:serapeum #:function-cache) + (:use #:common-lisp #:trivial-gray-streams #:alexandria #:serapeum) (:export #:eris-encode #:eris-decode |