Class: Philiprehberger::Lru::Node Private

Inherits:
Object
  • Object
show all
Defined in:
lib/philiprehberger/lru.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.

Node for the doubly-linked list

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value, expires_at: nil) ⇒ Node

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 Node.



15
16
17
18
19
20
21
# File 'lib/philiprehberger/lru.rb', line 15

def initialize(key, value, expires_at: nil)
  @key = key
  @value = value
  @expires_at = expires_at
  @prev_node = nil
  @next_node = nil
end

Instance Attribute Details

#expires_atObject

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.



13
14
15
# File 'lib/philiprehberger/lru.rb', line 13

def expires_at
  @expires_at
end

#keyObject

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.



13
14
15
# File 'lib/philiprehberger/lru.rb', line 13

def key
  @key
end

#next_nodeObject

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.



13
14
15
# File 'lib/philiprehberger/lru.rb', line 13

def next_node
  @next_node
end

#prev_nodeObject

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.



13
14
15
# File 'lib/philiprehberger/lru.rb', line 13

def prev_node
  @prev_node
end

#valueObject

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.



13
14
15
# File 'lib/philiprehberger/lru.rb', line 13

def value
  @value
end

Instance Method Details

#expired?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)


23
24
25
26
27
# File 'lib/philiprehberger/lru.rb', line 23

def expired?
  return false if @expires_at.nil?

  Time.now >= @expires_at
end