README.md in lru_redux-0.0.4 vs README.md in lru_redux-0.0.5

- old
+ new

@@ -24,50 +24,65 @@ ```ruby require 'lru_redux' # non thread safe -cache = LruRedux::Cache(100) +cache = LruRedux::Cache.new(100) cache[:a] = "1" cache[:b] = "2" + +cache.to_a +# [[:b,"2"],[:a,"1"]] +# note the order matters here, last accessed is first + cache[:a] # a pushed to front # "1" cache.to_a # [[:a,"1"],[:b,"2"]] cache.delete(:a) cache.each {|k,v| p "#{k} #{v}"} -# nothing +# b 2 + cache.max_size(200) # cache now stores 200 items cache.clear # cache has no items +cache.getset(:a){1} +cache.to_a +#[[:a,1]] + +# already set so don't call block +cache.getset(:a){99} +cache.to_a +#[[:a,1]] + # for thread safe access, all methods on cache # are protected with a mutex cache = LruRedux::ThreadSafeCache(100) ``` ## Benchmarks -see: benchmark directory +see: benchmark directory (a million random lookup / store) ``` sam@ubuntu:~/Source/lru_redux/bench$ ruby ./bench.rb Rehearsal --------------------------------------------------------- -thread safe lru 27.640000 0.370000 28.010000 ( 28.049021) -lru gem 2.460000 0.000000 2.460000 ( 2.454292) -lru_cache gem 2.170000 0.000000 2.170000 ( 2.174306) -lru_redux gem 1.530000 0.020000 1.550000 ( 1.552481) -lru_redux thread safe 2.610000 0.070000 2.680000 ( 2.684895) ------------------------------------------------ total: 36.870000sec +thread safe lru 27.940000 0.020000 27.960000 ( 28.026869) +lru gem 2.250000 0.010000 2.260000 ( 2.256652) +lru_cache gem 1.980000 0.000000 1.980000 ( 1.979244) +lru_redux gem 1.190000 0.000000 1.190000 ( 1.187640) +lru_redux thread safe 2.480000 0.000000 2.480000 ( 2.486314) +----------------------------------------------- total: 35.870000sec user system total real -thread safe lru 28.170000 0.280000 28.450000 ( 28.465008) -lru gem 2.330000 0.000000 2.330000 ( 2.328316) -lru_cache gem 2.140000 0.000000 2.140000 ( 2.142749) -lru_redux gem 1.640000 0.000000 1.640000 ( 1.643732) -lru_redux thread safe 2.590000 0.000000 2.590000 ( 2.600422) +thread safe lru 28.010000 0.000000 28.010000 ( 28.023534) +lru gem 2.250000 0.000000 2.250000 ( 2.256425) +lru_cache gem 1.920000 0.000000 1.920000 ( 1.925362) +lru_redux gem 1.170000 0.000000 1.170000 ( 1.170970) +lru_redux thread safe 2.480000 0.000000 2.480000 ( 2.488169) ``` ## Contributing @@ -77,9 +92,14 @@ 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request ## Changlog + +###version 0.0.5 - 23-April-2013 + +- Added getset and fetch +- Optimised implementation so it 20-30% faster on Ruby 1.9+ ###version 0.0.4 - 23-April-2013 - Initial version