Class: KNSEmailEndpoint::Storage::MemcacheStorage
Class Attribute Summary collapse
#message_id, #retry_count, #state, #unique_id
Instance Method Summary
collapse
#find_or_create, #to_h
Constructor Details
Returns a new instance of MemcacheStorage.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/kns_email_endpoint/storage/memcache_storage.rb', line 9
def initialize(settings)
options = {
:host => "localhost",
:port => 11211,
:ttl => nil
}.merge!(settings)
self.class.client ||= Dalli::Client.new("#{options[:host]}:#{options[:port]}")
@client = self.class.client
@ttl = options[:ttl]
end
|
Class Attribute Details
.client ⇒ Object
Returns the value of attribute client.
6
7
8
|
# File 'lib/kns_email_endpoint/storage/memcache_storage.rb', line 6
def client
@client
end
|
Instance Method Details
#create(opts = {}) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/kns_email_endpoint/storage/memcache_storage.rb', line 26
def create(opts={})
options = {
:state => :unprocessed,
:retry_count => 0
}.merge! opts
raise ":unique_id is required" unless options[:unique_id]
raise ":message_id is required" unless options[:message_id]
set_vars(options)
save!
return true
end
|
#delete ⇒ Object
51
52
53
54
55
56
|
# File 'lib/kns_email_endpoint/storage/memcache_storage.rb', line 51
def delete
return false unless @unique_id
@client.delete @unique_id
reset_storage
return true
end
|
#delete_all ⇒ Object
58
59
60
61
62
|
# File 'lib/kns_email_endpoint/storage/memcache_storage.rb', line 58
def delete_all
@client.flush
reset_storage
return true
end
|
#find(unique_id) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/kns_email_endpoint/storage/memcache_storage.rb', line 40
def find(unique_id)
s = @client.get(unique_id)
if s
set_vars(s)
return self
else
reset_storage
return nil
end
end
|