Class: UserSettings::Key

Inherits:
Object
  • Object
show all
Defined in:
app/models/user_settings/key.rb

Class Method Summary collapse

Class Method Details

.create(user_id, key, value) ⇒ Object



8
9
10
11
12
13
14
# File 'app/models/user_settings/key.rb', line 8

def create(user_id, key, value)
  if find(user_id, key)
    false
  else
    create_or_update(user_id, key, value)
  end
end

.create_or_update(user_id, key, value = nil) ⇒ Object



4
5
6
# File 'app/models/user_settings/key.rb', line 4

def create_or_update(user_id, key, value = nil)
  UserSettings.redis.setex redisable_key(user_id, key), UserSettings.expiration_time, value
end

.destroy(user_id, key) ⇒ Object



20
21
22
# File 'app/models/user_settings/key.rb', line 20

def destroy(user_id, key)
  UserSettings.redis.del redisable_key(user_id, key)
end

.find(user_id, key) ⇒ Object



16
17
18
# File 'app/models/user_settings/key.rb', line 16

def find(user_id, key)
  UserSettings.redis.get redisable_key(user_id, key)
end