Method: Redis::Commands::Strings#set
- Defined in:
- lib/redis/commands/strings.rb
#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.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/redis/commands/strings.rb', line 83 def set(key, value, ex: nil, px: nil, exat: nil, pxat: nil, nx: nil, xx: nil, keepttl: nil, get: nil) args = [:set, 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(args, &BoolifySet) else send_command(args) end end |