Sha256: fdb530ee78bbfad7205871b73ae5da9483811e0fd81bafb1098701161d0aae8d

Contents?: true

Size: 1.24 KB

Versions: 13

Compression:

Stored size: 1.24 KB

Contents

#          Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

require File.expand_path('../../../../spec/helper', __FILE__)

describe Ramaze::Cache::LRU do
  Ramaze.options.cache.names = [:one, :two]
  Ramaze.options.cache.default = Ramaze::Cache::LRU
  Ramaze.setup_dependencies

  cache = Ramaze::Cache.one
  hello = 'Hello, World!'

  should 'store without ttl' do
    cache.store(:hello, hello).should == hello
  end

  should 'fetch' do
    cache.fetch(:hello).should == hello
  end

  should 'delete' do
    cache.delete(:hello)
    cache.fetch(:hello).should == nil
  end

  should 'delete two key/value pairs at once' do
    cache.store(:hello, hello).should == hello
    cache.store(:ramaze, 'ramaze').should == 'ramaze'
    cache.delete(:hello, :ramaze)
    cache.fetch(:hello).should == nil
    cache.fetch(:innate).should == nil
  end

  should 'store with ttl' do
    cache.store(:hello, @hello, :ttl => 0.2)
    cache.fetch(:hello).should == @hello
    sleep 0.3
    cache.fetch(:hello).should == nil
  end

  should 'clear' do
    cache.store(:hello, @hello)
    cache.fetch(:hello).should == @hello
    cache.clear
    cache.fetch(:hello).should == nil
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
manveru-ramaze-2009.07 spec/ramaze/cache/lru.rb
ramaze-2011.12.28 spec/ramaze/cache/lru.rb
ramaze-2011.10.23 spec/ramaze/cache/lru.rb
ramaze-2011.07.25 spec/ramaze/cache/lru.rb
ramaze-2011.01.30 spec/ramaze/cache/lru.rb
ramaze-2011.01 spec/ramaze/cache/lru.rb
ramaze-2010.06.18 spec/ramaze/cache/lru.rb
ramaze-2010.04.04 spec/ramaze/cache/lru.rb
ramaze-2010.04 spec/ramaze/cache/lru.rb
ramaze-2010.03 spec/ramaze/cache/lru.rb
ramaze-2010.01 spec/ramaze/cache/lru.rb
ramaze-2009.10 spec/ramaze/cache/lru.rb
ramaze-2009.07 spec/ramaze/cache/lru.rb