Module: RedisModel::Types::Base

Included in:
BaseValue, Hash, List, Set, SortedSet
Defined in:
lib/redis_model/types/base.rb

Overview

Internal: Provides methods for Redis commands related to plain key operations and helpers.

Instance Method Summary collapse

Instance Method Details

#connectionObject

Public: Helper method for global Redis connection.

Returns global Redis connection object.



27
28
29
# File 'lib/redis_model/types/base.rb', line 27

def connection
  RedisModel::Base.connection
end

#delObject Also known as: clear

Public: Removes Redis value associated with the key using Redis command DEL.

Returns 1 if key is deleted, 0 otherwise.



18
19
20
# File 'lib/redis_model/types/base.rb', line 18

def del
  connection.del(key_label)
end

#exists?Boolean

Public: Asserts existence of Redis key having the label using Redis command ExiSTS.

Returns true if key exists, false otherwise.

Returns:

  • (Boolean)


10
11
12
# File 'lib/redis_model/types/base.rb', line 10

def exists?
  connection.exists(key_label)
end