Module: Valkey::Commands::Strings
- Included in:
- Valkey::Commands
- Defined in:
- lib/valkey/commands/strings.rb
Overview
This module contains commands related to strings.
Instance Method Summary collapse
-
#get(key) ⇒ String
Get the value of a key.
-
#set(key, value, ex: nil, px: nil, exat: nil, pxat: nil, nx: nil, xx: nil, keepttl: nil, get: nil) ⇒ String, Boolean
Set the string value of a key.
Instance Method Details
#get(key) ⇒ String
Get the value of a key.
43 44 45 |
# File 'lib/valkey/commands/strings.rb', line 43 def get(key) send_command(RequestType::GET, [key]) end |
#set(key, value, ex: nil, px: nil, exat: nil, pxat: nil, nx: nil, xx: nil, keepttl: nil, get: nil) ⇒ String, Boolean
Set the string value of a key.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/valkey/commands/strings.rb', line 21 def set(key, value, ex: nil, px: nil, exat: nil, pxat: nil, nx: nil, xx: nil, keepttl: nil, get: nil) args = [key, value.to_s] args << "EX" << Integer(ex) if ex args << "PX" << Integer(px) if px args << "EXAT" << Integer(exat) if exat args << "PXAT" << Integer(pxat) if pxat args << "NX" if nx args << "XX" if xx args << "KEEPTTL" if keepttl args << "GET" if get if nx || xx send_command(RequestType::SET(args, &BoolifySet)) else send_command(RequestType::SET, args) end end |