Module: Rublox::Cache

Defined in:
lib/rublox/util/cache.rb

Overview

Note:

Only use if you have an use case that the library doesn’t cover (and create an issue and perhaps we’ll implement it!).

Constant Summary collapse

USER =

The key for the user cache.

:users
GROUP =

The key for the group cache.

:groups
PAGE =

The key for the page cache.

:pages

Class Method Summary collapse

Class Method Details

.get(type, id) ⇒ FullUser, ...

Try to get an object from cache.

Parameters:

  • type (Symbol)
  • id (Integer)

    the ID of the object

Returns:



25
26
27
# File 'lib/rublox/util/cache.rb', line 25

def self.get(type, id)
  @cache[type][id]
end

.set(type, id, object) ⇒ nil

Set an object in the cache, under the type’s key.

Parameters:

  • type (Symbol)
  • id (Integer)

    the ID of the object

  • object (FullUser, FullGroup, Pages)

    the object to be added to the cache

Returns:

  • (nil)


35
36
37
# File 'lib/rublox/util/cache.rb', line 35

def self.set(type, id, object)
  @cache[type][id] = object
end