Class: Picky::Backends::Redis::Basic

Inherits:
Object
  • Object
show all
Defined in:
lib/picky/backends/redis/basic.rb

Overview

Redis Backend Accessor.

Provides necessary helper methods for its subclasses. Not directly useable, as it does not provide dump/load methods.

Direct Known Subclasses

List, String

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, namespace, options = {}) ⇒ Basic

An index cache takes a path, without file extension, which will be provided by the subclasses.



21
22
23
24
25
26
27
28
# File 'lib/picky/backends/redis/basic.rb', line 21

def initialize client, namespace, options = {}
  @client    = client
  @namespace = namespace

  @empty    = options[:empty]
  @initial  = options[:initial]
  @realtime = options[:realtime]
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



16
17
18
# File 'lib/picky/backends/redis/basic.rb', line 16

def client
  @client
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



16
17
18
# File 'lib/picky/backends/redis/basic.rb', line 16

def namespace
  @namespace
end

Instance Method Details

#emptyObject

The empty index that is used for putting the index together.



33
34
35
# File 'lib/picky/backends/redis/basic.rb', line 33

def empty
  @empty && @empty.clone || (@realtime ? self.reset : {})
end

#initialObject

The initial content before loading.

Note: As Redis indexes needn’t be loaded per se,

this just returns the same thing as #load.


42
43
44
# File 'lib/picky/backends/redis/basic.rb', line 42

def initial
  @initial && @initial.clone || (@realtime ? self.reset : {})
end

#load(_) ⇒ Object

Returns itself.



48
49
50
# File 'lib/picky/backends/redis/basic.rb', line 48

def load _
  self
end

#resetObject

Clears the whole namespace.



60
61
62
63
# File 'lib/picky/backends/redis/basic.rb', line 60

def reset
  clear
  self
end

#retrieveObject

We do not use Redis to retrieve data.



54
55
56
# File 'lib/picky/backends/redis/basic.rb', line 54

def retrieve
  # Nothing.
end

#to_sObject



67
68
69
# File 'lib/picky/backends/redis/basic.rb', line 67

def to_s
  "#{self.class}(#{namespace}:*)"
end