chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] memcached


From: Alaric Snell-Pym
Subject: Re: [Chicken-users] memcached
Date: Wed, 20 Jun 2007 10:55:07 +0100


On 20 Jun 2007, at 10:19 am, Dan Muresan wrote:

Ok, so that's one vote for separate 'memcached' and 'cache' eggs.

I would vote against a generically-named cache egg... There are
many types of caches (depending on storage medium, indexing, time
complexities of caching/retrieval, expiration strategies etc)

That's why my generic cache interface is intended to be a front-end
to different cache implementations, with a common interface, and some
tools built on top of that interface (such as memoizing functions).

I've not settled on an API yet, but I can imagine something like:

(require-extension cache)

;; for production:

(require-extension memcached)
(define my-cache (make-memcached-cache
  '(("cache1.example.com" 11211 1)   ; hostname, port, weighting
    ("cache2.example.com" 11211 1)
    ("cache3.example.com" 11211 1))

;; for development:

; Store up to 256 objects, maximum 64Kb, in memory, LRU
; (define my-cache (make-lru-memory-cache 256 65536))

;; From here on, we are independent of the cache implementation

(cache-set! my-cache foo bar) ; store bar under key foo
(cache-get my-cache foo) ; and get it back again

(define (factor x) (...split x into prime factors...))
(define memoized-factor (memoize-with-cache my-cache factor))

(memoized-factor
205872349782348907340789347890213478900784578923402379023478902390783480
79458079213407891234890)
; should be quick the second time!
(memoized-factor
205872349782348907340789347890213478900784578923402379023478902390783480
79458079213407891234890)

Best,
Dan

ABS

--
Alaric Snell-Pym
Work: http://www.snell-systems.co.uk/
Play: http://www.snell-pym.org.uk/alaric/
Blog: http://www.snell-pym.org.uk/?author=4






reply via email to

[Prev in Thread] Current Thread [Next in Thread]