Class: Stockpot::RedisController
Instance Method Summary
collapse
#rescue_error, #return_error
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/stockpot/redis_controller.rb', line 17
def create
if params[:field].present?
REDIS.hset(params[:key], params[:field], params[:value])
else
REDIS.set(params[:key], params[:value])
end
render json: { status: 201 }
end
|
#index ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
|
# File 'app/controllers/stockpot/redis_controller.rb', line 5
def index
if params[:field].present?
record = REDIS.hget(params[:key], params[:field])
else
record = REDIS.get(params[:key])
end
render json: record.to_json, status: :ok
end
|
#keys ⇒ Object
29
30
31
32
33
|
# File 'app/controllers/stockpot/redis_controller.rb', line 29
def keys
record = REDIS.keys
render json: record.to_json, status: :ok
end
|