-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
51 lines (38 loc) · 1.52 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Just initialize the cache, by configuring your store.
Just add the configuration to your config initializers
require 'cachet'
Cachet.setup do |config|
config.logger = Rails.logger
config.storage = Cachet::FileStore.new("/pal_storage/path")
config.enabled = true
# The followings are the configurations that you can do on file store
# The given values are the default ones, if you are OK with them you don't need
# to configure at all.
# You can set whether you want directory optimization or not
# file_store.optimize = TRUE
# The depth of directories you want
# file_store.dir_levels = 3
# Number of directories within a directory, it is better if you use a prime number
# but something other than 31, that is the one we use for hashing :)
# file_store.dir_count = 19
end
And from this point forward , if you want return values of your methods to be cached;
#include cacheable module , which will add two class macros to mark a method as cacheable and also as cache invalidator.
You should pass blocks to these marcos which will return cache keys. Use exact signature of the method that you are referring in the block that returns the key.
class Sample
include Cachet::Cacheable
def first (param1, param2)
puts "First is running"
return "First"
end
def second (param1, param2)
puts "Second is running and invalidating for #{param1}"
return "First"
end
cacheable :first, :car do |param1, param2|
param1
end
cache_invalidator :second, :car do |param1, param2|
param1
end
end