Class: Ukiryu::Cache::Entry Private

Inherits:
Object
  • Object
show all
Defined in:
lib/ukiryu/cache.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Cache entry with expiration tracking

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Entry

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Entry.



23
24
25
26
27
# File 'lib/ukiryu/cache.rb', line 23

def initialize(value)
  @value = value
  @created_at = Time.now
  @accessed_at = @created_at
end

Instance Attribute Details

#accessed_atObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
# File 'lib/ukiryu/cache.rb', line 21

def accessed_at
  @accessed_at
end

#created_atObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
# File 'lib/ukiryu/cache.rb', line 21

def created_at
  @created_at
end

#valueObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
# File 'lib/ukiryu/cache.rb', line 21

def value
  @value
end

Instance Method Details

#expired?(ttl) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


33
34
35
36
37
# File 'lib/ukiryu/cache.rb', line 33

def expired?(ttl)
  return false unless ttl

  (Time.now - @created_at) > ttl
end

#touch!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/ukiryu/cache.rb', line 29

def touch!
  @accessed_at = Time.now
end