Sha256: e07f9e8c231958219b8a158ab8c8c77c9dd65aef3b6b86dc8a239526e2fb7339

Contents?: true

Size: 1020 Bytes

Versions: 1

Compression:

Stored size: 1020 Bytes

Contents

require File.join(File.dirname(__FILE__), 'CONFIG.rb')

$DBG = true

require 'rubygems'
require 'facets'
require 'test/unit'

require 'og'
require 'glue/cacheable'
require 'glue/cache/memory'
#require 'glue/cache/drb'

class TC_Cacheable < Test::Unit::TestCase # :nodoc: all
  include Glue
  
  class User
    is Cacheable
    
    property :name, String
    property :age, Fixnum
  end

  def setup
    @og = Og.start
    @og.cache = MemoryCache.new
#   @og.cache = DrbCache.new(:address => Og.cache_address, :port => Og.cache_port)
  end

  def test_all
    User.create_with :name => 'George'
    User.create_with :name => 'Stella'
    
    u = User[1]
    
    assert_equal 'George', u.name

    # Comes from the cache.
    
    u = User[1]
    u = User[1]
    u = User[1]

    assert_equal u, @og.cache.get(u.og_cache_key)
        
    u.name = 'Hello'
    u.save
    
    u = User[1]
    u = User[1]
    
    assert_equal u.name, @og.cache.get(u.og_cache_key).name
    
    u.delete
    User.delete(2)
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
og-0.28.0 test/og/tc_cacheable.rb