X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=sql%2Futils.lisp;h=6e4230d84d94486d8448cc9c84f9c89839bd47e4;hp=60fedc3f971d4a8fd6b9b2d39471dfcb5350064d;hb=bab5e8056e3850cd9fb0582f73955aee5abf010b;hpb=084aa8d0bcfd2e07d0f7b267f27440191d699268 diff --git a/sql/utils.lisp b/sql/utils.lisp index 60fedc3..6e4230d 100644 --- a/sql/utils.lisp +++ b/sql/utils.lisp @@ -405,3 +405,22 @@ removed. keys are searched with #'MEMBER" unless (member k keys-to-remove) collect k and collect v while rest))) + +(defmacro make-weak-hash-table (&rest args) + "Creates a weak hash table for use in a cache." + `(progn + + ;;NB: These are generally used for caches that may not have an alternate + ;;clearing mechanism. If you are on an implementation that doesn't support + ;;weak hash tables then you're memory may accumulate. + + #-(or sbcl allegro clisp lispworks) + (warn "UNSAFE! use of weak hash on implementation without support. (see clsql/sql/utils.lisp to add)") + + (make-hash-table + #+allegro :values #+allegro :weak + #+clisp :weak #+clisp :value + #+lispworks :weak-kind #+lispworks :value + #+sbcl :weakness #+sbcl :value + ,@args) + ))