i'm observing some behavior using Cache::Cache that seems
odd, altho it may be due to my faulty understanding of how
the interface works.

i'm using Cache::MemoryCache to manage a cache of session
objects in a non-forking apache process. once i've initially
called set to store a session object using its session id as
the key, i then call get a couple of times per request to
get the session object out of the cache. problem is, each
time i call get, i'm apparently getting a different instance
of the session class! furthermore, each instance's variables
are the values that were originally set at creation time,
regardless of whether i update the variables during later
requests or not.

here's a snippet of my debug output for two subsequence
requests:

# first request. the server has just started, so there are
# no cached sessions (the requested session id refers to an
# invalid session). we create a new session (with a new id),
# set it in the cache, then get it back out for later use.
# notice the final get call seems to return a different
# instance than the set call!

get session for id [39a0a4ce81943263b25474c20b087586]:
get session for id [39a0a4ce81943263b25474c20b087586]:
get session for id [b2ac8e8d51f4512c4bcf8476126f54a5]:
set session for id [b2ac8e8d51f4512c4bcf8476126f54a5]: 
Wombat::Core::Session=ARRAY(0x886a838)
get session for id [b2ac8e8d51f4512c4bcf8476126f54a5]: 
Wombat::Core::Session=ARRAY(0x88863bc)

# second request. each get call is finding /something/ for
# the given key, but again it seems to be a different
# instance each time!

get session for id [b2ac8e8d51f4512c4bcf8476126f54a5]: 
Wombat::Core::Session=ARRAY(0x88bc8f4)
get session for id [b2ac8e8d51f4512c4bcf8476126f54a5]: 
Wombat::Core::Session=ARRAY(0x88c06dc)

i see this behavior regardless of whether i'm using
Cache::MemoryCache with a non-forking apache or
Cache::SharedMemoryCache with a forking apache. so i feel
that either i'm doing something wrong in my usage of the
Cache::Cache interface, or i'm overlooking some obvious perl
behavior.

any idea what might be going wrong?

Reply via email to