Idiomdrottning’s homepage

schlemoize

Just so I could cache some values.

(define zbd #f)

(define (get-stored key)
  ((or zbd
       (begin
         (set! zbd
               (call-table
                seed:
                (with-input-from-file "/home/sandra/.zbd.scm"
                  read-list)))
         zbd))
   key))

(define (store key . vals)
  (with-output-to-file "/home/sandra/.zbd.scm"
    (fn (write (cons key vals)))
    #:append)
  (apply values
         (if zbd
             (zbd key vals)
             vals)))

(define ((schlemoize func) key)
  (eif (get-stored key)
       (apply values it)
       (->>* (func key) (store key))))

Probably the slowest database in the world but I’m too exhausted to try to grok the docs of something like LMDB or TokyoCabinet.

I clear it out with cron.