public
Description: Tracks the keys added to an instance of MemCache
Clone URL: git://github.com/jamescook/memcache_keys_script.git
Added namespace attribute to serialization
jamescook (author)
Tue Jul 15 18:54:25 -0700 2008
commit  fc3a2af82e8a003f0bc8a1c62c8c3a4686ab88eb
tree    4eaba01966caa1df8cacadcee277b98ddbcdf092
parent  b5c439d19ece27276201ee81ca4c7218597b9913
0
...
30
31
32
33
34
 
 
 
 
 
 
35
...
30
31
32
 
33
34
35
36
37
38
39
40
0
@@ -30,4 +30,9 @@ Example usage:
0
  --> NEWCACHE = MemCache.load_instance(File.read('my_cached_data'))
0
  =#> <MemCache: 1 servers, 1 buckets, ns: nil, ro: false>
0
  --> NEWCACHE.keys
0
- =#> [:test]
0
\ No newline at end of file
0
+ =#> [:test]
0
+
0
+
0
+
0
+
0
+-- TODO: Handle all the attributes when serializing ..
0
\ No newline at end of file
...
32
33
34
35
 
36
37
38
...
50
51
52
53
 
 
54
55
56
 
57
58
59
...
32
33
34
 
35
36
37
38
...
50
51
52
 
53
54
55
56
 
57
58
59
60
0
@@ -32,7 +32,7 @@ class MemCache
0
   # Take an instance of MemCache and dump that data, with a dash of clever-ness to prevent Marshal
0
   # from having a fit. Now you can save your cached objects to disk ...
0
   def serialize
0
- data = {'server_string' => self.servers_hash}
0
+ data = {'cache_settings' => {'server_string' => self.servers_hash, 'namespace' => self.namespace}}
0
     if(MemCache.const_defined?(:KEYS))
0
       MemCache::KEYS.each do |key,val|
0
         # get the data for each key we have tracked
0
@@ -50,10 +50,11 @@ class MemCache
0
   # new instance of MemCache with the below method
0
   def self.load_instance(byte_stream)
0
     data = Marshal.load(byte_stream)
0
- servers = data['server_string']
0
+ settings = data['cache_settings']
0
+ servers = settings['server_string']
0
     data.shift
0
     # The remaining key/values are bits of data in a former instance of MemCache
0
- cache = MemCache.new
0
+ cache = MemCache.new(:namespace => settings['namespace'])
0
     cache.servers = servers
0
     data.each do |k,v|
0
       cache.set(k.to_s,v)

Comments

    No one has commented yet.