Class: Herve::Cache
- Inherits:
-
Object
show all
- Defined in:
- lib/herve/cache.rb,
lib/herve/cache/entry.rb,
lib/herve/cache/shard.rb,
lib/herve/cache/timestamp.rb
Defined Under Namespace
Classes: Entry, Shard, Timestamp
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(root) ⇒ Cache
Returns a new instance of Cache.
17
18
19
|
# File 'lib/herve/cache.rb', line 17
def initialize(root)
@root = root
end
|
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root.
9
10
11
|
# File 'lib/herve/cache.rb', line 9
def root
@root
end
|
Class Method Details
.digest(data) ⇒ Object
12
13
14
|
# File 'lib/herve/cache.rb', line 12
def digest(data)
Digest::XXH3_64bits.hexdigest(data)
end
|
Instance Method Details
#bucket(bucket_type) ⇒ Object
21
22
23
|
# File 'lib/herve/cache.rb', line 21
def bucket(bucket_type)
root.join(bucket_path(bucket_type))
end
|
#entry(bucket_type, dir, file) ⇒ Object
29
30
31
|
# File 'lib/herve/cache.rb', line 29
def entry(bucket_type, dir, file)
Entry.new(bucket(bucket_type).join(dir), file)
end
|
#shard(bucket_type, dir) ⇒ Object
25
26
27
|
# File 'lib/herve/cache.rb', line 25
def shard(bucket_type, dir)
Shard.new(bucket(bucket_type).join(dir))
end
|