Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the clache Reference Manual, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 12:59:28 2020 GMT+0.
• Introduction | What clache is all about | |
• Systems | The systems documentation | |
• Modules | The modules documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
CLACHE is a general caching library for Common Lisp.
CLACHE provides a general caching facility for Common Lisp. The API is similar with standard hash-table interface. Let me show you an overview of API.
getcache
- Get cache from storagesetcache
- Store cache into storageremcache
- Remove cache from storageclrcache
- Clear all cache in storageAs you can see, it is easy to use. Here is an example:
;; Create a store
(defparamater *store* (progn
(ensure-directories-exist #p"cache/")
(make-instance 'file-store :directory #p"cache/")))
;; Store cache
(setcache 1 "foo" *store*)
;;=> 1
;; Get cache
(getcache 1 *store*)
;;=> 1, T
;; Get non-exited cache
(getcache 42 *store*)
;;=> NIL, NIL
;; Remove cache
(remcache 1 *store*)
;;=> T
;; Clear all cache
(clrcache *store*)
A cache is a triple of a key, a value, and an expiration time.
Any object can be used as a cache key if the object can be converted
into a string properly by using cache-key-to-string
.
Same as cache keys, any object can be used as a cache value. However, a type of cache values can be limited by storages. So you have to be careful what storage are you using.
An expiration time describes how long caches live in seconds. If an
expiration time is nil
, such caches will never be expired:
persistent cache.
If a cache is stored in a storage and has not yet been expired or a persitent cache, we express the cache exists in the storage.
Storage is an abstract layer of maintaining caches. You can access storages via API.
getcache
getcache key storage
Retrieve a cache value from storage
indicated by key
and return
values of the cache value and a boolean whether the cache exists in
storage
. The cache value will be nil
if such the cache doesn't
exist. For example, (getcache "not-existed-cache")
will return nil
,
nil
.
setcache
setcache key value storage &optional expire
Store a cache value
into storage
with key
and expire
. expire
is an expiration time in seconds. If expire
is nil
, the cache will
never be expired. The return value is value
that has been stored.
(setf getcache)
(setf getcache) value key storage &optional expire
Same as setcache
.
remcache
remcache key storage
Remove a cache from storage
indicated by key
. If the cache has
been successfully removed, this function returns t
, otherwise
returns nil
.
clrcache
clrcache storage
Remove all caches from storage
. The return value is undefined.
with-cache
cache
Copyright (C) 2011 Tomohiro Matsuyama <tomo@cx4a.org>
Next: Modules, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The clache system |
Olexiy Zamkoviy
Tomohiro Matsuyama
LLGPL
clache.asd (file)
src (module)
Modules are listed depth-first from the system components tree.
• The clache/src module | ||
• The clache/src/stores module |
Next: The clache/src/stores module, Previous: Modules, Up: Modules [Contents][Index]
clache (system)
src/
Previous: The clache/src module, Up: Modules [Contents][Index]
protocol.lisp (file)
src (module)
src/stores/
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
Next: The clache/src/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
clache.asd
clache (system)
Next: The clache/src/utils․lisp file, Previous: The clache․asd file, Up: Lisp files [Contents][Index]
Next: The clache/src/protocol․lisp file, Previous: The clache/src/package․lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
src (module)
src/utils.lisp
Next: The clache/src/stores/memory․lisp file, Previous: The clache/src/utils․lisp file, Up: Lisp files [Contents][Index]
utils.lisp (file)
src (module)
src/protocol.lisp
expire (type)
Next: The clache/src/stores/file․lisp file, Previous: The clache/src/protocol․lisp file, Up: Lisp files [Contents][Index]
stores (module)
src/stores/memory.lisp
hash-table-of (method)
Next: The clache/src/api․lisp file, Previous: The clache/src/stores/memory․lisp file, Up: Lisp files [Contents][Index]
memory.lisp (file)
stores (module)
src/stores/file.lisp
Previous: The clache/src/stores/file․lisp file, Up: Lisp files [Contents][Index]
stores (module)
src (module)
src/api.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The clache-asd package | ||
• The clache package |
Next: The clache package, Previous: Packages, Up: Packages [Contents][Index]
clache.asd
Previous: The clache-asd package, Up: Packages [Contents][Index]
package.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported macros | ||
• Exported functions | ||
• Exported generic functions | ||
• Exported classes |
Next: Exported functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Annotation for caching functions with their arguments. This should
be used with CL-ANNOT. KEYARGS is a form or a list of form for making
a cache key. To make cache keys distinct as to the function, you may
add a keyword or a symbol into KEYARGS. See also WITH-CACHE.
Example:
@cache ((:f x y z))
(defun f (x y z)
...)
;; Remove a cache of F
(remcache ’(:f 1 2 3))
If a cache indicated by KEY exists, this just returns the cache
value without evaluating BODY. Otherwise, this evaluates BODY and
stores the evaluated value into STORE with KEY and EXPIRE. KEY is a
form that an evaluated value indicates the cache key.
Example:
(defun f (x)
(with-cache (x *store*)
(very-complex-computation x)))
Same as WITH-CACHE, except that an inline memory store will be used as a cache store. TEST is a function to test hash table keys of the memory store. WEAKNESS specifies the hash table is weak-hash-table or not.
Next: Exported generic functions, Previous: Exported macros, Up: Exported definitions [Contents][Index]
Remove all caches from STORE. The return value is undefined.
Retrieve a cache value from STORE indicated by KEY and return values of the cache value and a boolean whether the cache exists in STORE. The cache value will be NIL if such the cache doesn’t exist. For example, (getcache "not-existed-cache") will return NIL, NIL.
api.lisp (file)
(setf getcache) (function)
Return T if EXPIRE represents caches will never be expired.
protocol.lisp (file)
Remove a cache from STORE indicated by KEY. If the cache has been successfully removed, this function returns T, otherwise returns NIL.
Store a cache VALUE into STORE with KEY and EXPIRE. EXPIRE is an expiration time in seconds. If EXPIRE is NIL, the cache will never be expired. The return value is VALUE that has been stored.
Next: Exported classes, Previous: Exported functions, Up: Exported definitions [Contents][Index]
This function converts any type of KEY into
string. This should be an injective function, meaning this should not
lose the information about key.
protocol.lisp (file)
Remove all caches from STORE. Any object can be returned.
protocol.lisp (file)
file.lisp (file)
memory.lisp (file)
Remove a cache indicated by KEY from STORE. If the
cache has been successfully removed, this function should return T,
otherwise should return NIL.
protocol.lisp (file)
file.lisp (file)
memory.lisp (file)
Try to retrieve a cache indicated by KEY from STORE
and return values of the cache value and a boolean whether the cache
exists in STORE. The cache value should be NIL if such the cache
doesn’t exist or has been expired.
protocol.lisp (file)
file.lisp (file)
memory.lisp (file)
Store a cache VALUE with KEY into STORE. EXPIRE is
a keep time in seconds. If EXPIRE is NIL, the cache will never
expired. This function should return the value that has been
stored.
protocol.lisp (file)
file.lisp (file)
memory.lisp (file)
Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
file.lisp (file)
store (class)
:directory
(cl-annot.slot::required-argument :directory)
directory-of (generic function)
memory.lisp (file)
store (class)
:hash-table
(make-hash-table :test (function equal))
hash-table-of (generic function)
An abstract class of stores. All stores must inherit from this class.
protocol.lisp (file)
standard-object (class)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal functions | ||
• Internal generic functions | ||
• Internal types |
Next: Internal generic functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
Return a MD5 digest of STRING in hex string.
utils.lisp (file)
Convert OBJECT into string by using PRINC-TO-STRING if OBJECT is not a symbol, or by using SYMBOL-FQN if OBJECT is a symbol.
utils.lisp (file)
Return a fully qualified name of SYMBOL in string. For example, (symbol-fqn ’if) will return "COMMON-LISP:IF".
utils.lisp (file)
Next: Internal types, Previous: Internal functions, Up: Internal definitions [Contents][Index]
automatically generated reader method
memory.lisp (file)
Previous: Internal generic functions, Up: Internal definitions [Contents][Index]
Type for expiration time.
protocol.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | C F L M |
---|
Jump to: | C F L M |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
C D F G H L M N O R S W |
---|
Jump to: | (
C D F G H L M N O R S W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | D H S |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
D | |||
directory : | Exported classes | ||
| |||
H | |||
hash-table : | Exported classes | ||
| |||
S | |||
Slot, directory : | Exported classes | ||
Slot, hash-table : | Exported classes | ||
|
Jump to: | D H S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C E F M P S T |
---|
Jump to: | C E F M P S T |
---|