This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
keyed /
| name | age | message | |
|---|---|---|---|
| |
README.textile | Fri Aug 08 15:44:19 -0700 2008 | [mmcgrana] |
| |
TODO.textile | Thu Jul 24 06:51:53 -0700 2008 | [mmcgrana] |
| |
keyed.gemspec | Thu Jul 24 06:51:53 -0700 2008 | [mmcgrana] |
| |
lib/ | Thu Jul 24 06:51:53 -0700 2008 | [mmcgrana] |
| |
spec/ | Thu Jul 24 06:51:53 -0700 2008 | [mmcgrana] |
README.textile
Keyed
Everything-agnostic, pluggable-backend, threadsafe, lightweight Ruby cache interface library
Usage
cache =
Keyed::MemoryStore.new,
# Keyed::FileStore.new(:cache_dir => "/tmp/my_cache")
# Keyed::MemcachedStore.new(:host => "127.0.0.1:11211")
=> #<Keyed::MemoryStore:0x8bd44 @hash={} @mutex=#<Mutex:0x87708>>
cache.get("foo")
=> nil
cache.set("foo", "foo-cached")
=> "bar"
cache.get("foo")
=> "foo-cached"
cache.fetch("bar") { puts "caching"; "bar-cached"}
caching
=> "bar-cached"
cache.fetch("bar") { puts "caching"; "bar-cached" }
=> "bar-cached"
cache.expire("bar")
cache.get("bar")
=> nil
cache.expire_all
cache.get("foo")
=> nil
The initializers for the cache store classes are documented in their respective class files.
The instance methods to manipulate the resulting classes are all documented in abstract_store.rb.
Threadsaftey
Multiple threads can share a single keyed cache instance. Each stores use different mechanism to handle concurrency: the MemoryStore uses a mutex, the FileStore uses file locks, and the MemcachedStore uses a shared pool of single-threaded Memcached instances.
Dependencies
Keyed::MemcachedStore requires the memcached gem and connection_pool library, the other stores have no dependencies.




