Files

Class Index [+]

Quicksearch

UbiquoDesign::CacheManagers::Memcache

Memcache implementation for the cache manager

Constants

CONFIG
(Not documented)
DATA_TIMEOUT
(Not documented)

Protected Class Methods

connection() click to toggle source

Returns or initializes a memcache connection

    # File vendor/plugins/ubiquo_design/lib/ubiquo_design/cache_managers/memcache.rb, line 65
65:         def connection
66:           if @cache.blank?
67:             begin
68:               @cache = MemCache.new(CONFIG[:server])
69:             rescue
70:               Rails.logger.warn "Memcache Error: memcached servers are not available"
71:               raise MemcacheNotAvailable, "Memcache Error: memcached servers are not available"
72:             end
73:             if @cache.servers.empty?
74:               Rails.logger.warn "Memcache Error: memcached servers are not available"
75:               raise MemcacheNotAvailable, "Memcache Error: memcached servers are not available" if @cache.servers.empty?
76:             end
77:             @cache.servers.each do |s|
78:               if s.socket.blank?
79:                 Rails.logger.error "Memcache Error: memcached socket has no connection on #{s.instance_variable_get(:@host)}"
80:                 raise MemcacheNotAvailable, "Memcache Error: memcached socket has no connection on #{s.instance_variable_get(:@host)}"
81:               end
82:             end
83:           end
84:           @cache
85:         end
delete(content_id) click to toggle source

removes the widget content from the store

    # File vendor/plugins/ubiquo_design/lib/ubiquo_design/cache_managers/memcache.rb, line 55
55:         def delete content_id
56:           Rails.logger.debug "Widget cache expiration request for key #{content_id}"
57:           begin
58:             connection.delete crypted_key(content_id)
59:           rescue MemCache::MemCacheError, MemcacheNotAvailable
60:             raise CacheNotAvailable.new("Cache is not available, impossible to delete cache")
61:           end
62:         end
multi_retrieve(content_ids, crypted = true) click to toggle source

retrieves the widgets content by an array of content_ids

    # File vendor/plugins/ubiquo_design/lib/ubiquo_design/cache_managers/memcache.rb, line 28
28:         def multi_retrieve content_ids, crypted = true
29:           unless crypted
30:             crypted_content_ids = []
31:             content_ids.each do |c_id|
32:               crypted_content_ids << crypted_key(c_id)
33:             end
34:           else
35:             crypted_content_ids = content_ids
36:           end
37:           begin
38:             connection.get_multi crypted_content_ids
39:           rescue MemCache::MemCacheError, MemcacheNotAvailable
40:             raise CacheNotAvailable.new("Cache is not available, impossible to multi_retrieve")
41:           end
42:         end
retrieve(content_id) click to toggle source

retrieves the widget content identified by content_id

    # File vendor/plugins/ubiquo_design/lib/ubiquo_design/cache_managers/memcache.rb, line 19
19:         def retrieve content_id
20:           begin
21:             connection.get crypted_key(content_id)
22:           rescue MemCache::MemCacheError, MemcacheNotAvailable
23:             raise CacheNotAvailable.new("Cache is not available, impossible to retrieve")
24:           end
25:         end
store(content_id, contents, expiration_time) click to toggle source

Stores a widget content indexing by a content_id

    # File vendor/plugins/ubiquo_design/lib/ubiquo_design/cache_managers/memcache.rb, line 45
45:         def store content_id, contents, expiration_time
46:           begin
47:             exp_time = expiration_time || DATA_TIMEOUT
48:             connection.set crypted_key(content_id), contents, exp_time
49:           rescue MemCache::MemCacheError, MemcacheNotAvailable
50:             raise CacheNotAvailable.new("Cache is not available, memcached can not store the content")
51:           end
52:         end

Disabled; run with $DEBUG to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.