Class: RackJwtAegis::CacheAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/rack_jwt_aegis/cache_adapter.rb

Overview

Since:

  • 0.1.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CacheAdapter

Returns a new instance of CacheAdapter.

Since:

  • 0.1.0



20
21
22
# File 'lib/rack_jwt_aegis/cache_adapter.rb', line 20

def initialize(options = {})
  @options = options
end

Class Method Details

.build(store_type, options = {}) ⇒ Object

Since:

  • 0.1.0



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rack_jwt_aegis/cache_adapter.rb', line 5

def self.build(store_type, options = {})
  case store_type
  when :memory, :memory_store
    MemoryAdapter.new(options)
  when :redis, :redis_cache_store
    RedisAdapter.new(options)
  when :memcached, :mem_cache_store
    MemcachedAdapter.new(options)
  when :solid_cache, :solid_cache_store
    SolidCacheAdapter.new(options)
  else
    raise ConfigurationError, "Unsupported cache store: #{store_type}"
  end
end

Instance Method Details

#clearObject

Raises:

  • (NotImplementedError)

Since:

  • 0.1.0



41
42
43
# File 'lib/rack_jwt_aegis/cache_adapter.rb', line 41

def clear
  raise NotImplementedError, 'Subclass must implement #clear'
end

#delete(key) ⇒ Object

Raises:

  • (NotImplementedError)

Since:

  • 0.1.0



33
34
35
# File 'lib/rack_jwt_aegis/cache_adapter.rb', line 33

def delete(key)
  raise NotImplementedError, 'Subclass must implement #delete'
end

#exist?(key) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 0.1.0



37
38
39
# File 'lib/rack_jwt_aegis/cache_adapter.rb', line 37

def exist?(key)
  !read(key).nil?
end

#read(key) ⇒ Object

Abstract methods - must be implemented by subclasses

Raises:

  • (NotImplementedError)

Since:

  • 0.1.0



25
26
27
# File 'lib/rack_jwt_aegis/cache_adapter.rb', line 25

def read(key)
  raise NotImplementedError, 'Subclass must implement #read'
end

#write(key, value, expires_in: nil) ⇒ Object

Raises:

  • (NotImplementedError)

Since:

  • 0.1.0



29
30
31
# File 'lib/rack_jwt_aegis/cache_adapter.rb', line 29

def write(key, value, expires_in: nil)
  raise NotImplementedError, 'Subclass must implement #write'
end