Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kenoir/cachescade
JRuby Multi-Layer Cache Gem
https://github.com/kenoir/cachescade
Last synced: 9 days ago
JSON representation
JRuby Multi-Layer Cache Gem
- Host: GitHub
- URL: https://github.com/kenoir/cachescade
- Owner: kenoir
- License: gpl-3.0
- Created: 2014-02-23T13:25:13.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-02-28T10:15:38.000Z (almost 11 years ago)
- Last Synced: 2024-11-08T21:59:35.483Z (2 months ago)
- Language: Ruby
- Size: 223 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
cachescade
==========**work in progress**
JRuby Multi-Layer Cache Gem
Usage:
```rb
class CacheStub
attr_reader :hash, :sleep_timedef initialize(cache_speed)
@sleep_time = cache_speed
enddef get(id)
dozesleep @sleep_time
(not @hash.nil?) and @hash.include?(id) ? cache_hit_for(id) : cache_miss_for(id)
enddef put(id, data)
dozeputs "cache_put #{id}"
@hash.nil? ? (@hash = { id => data }) : @hash[id] = data
enddef doze
puts "sleeping for #{@sleep_time} seconds"
sleep @sleep_time
enddef cache_hit_for(id)
puts "cache_hit #{id}"
@hash[id]
enddef cache_miss_for(id)
puts "cache_miss #{id}"
nil
end
endc = Cachescade.create
c << Cachescade::CacheLayer.new(CacheStub.new(3))
c << Cachescade::CacheLayer.new(CacheStub.new(2))
c << Cachescade::CacheLayer.new(CacheStub.new(1))
```