I have next question:
I use the hset() procedure for Redis Server in python. This procedure is described here.
ok, now I couldn't understand the parameter value... From one hand it should be a number 0 or 1, anyway I could use also other numbers for this parameter (and I also find examples in net with other values). For example I define next def:
def setHashKeyValue(key, value, number):
assert (key != None), "Please, get a key"
#assert (number == 0 or number ==1), "Please enter 0 or 1"
redis_server.hset(key, value, number);
And got right output with the next parameters:
setHashKeyValue('5', 'test ok for key 5', 1)
setHashKeyValue('6', 'test ok for key 6', 1)
On the other hand, I would like to define some loop for time measuring, so I define next def:
def loopKeyValues(number):
timeUse = []
for x in range(number):
start = time.time()
setHashKeyValue(x, x**2, 1)
end = time. time()
timeUse.append(end-start)
plt.plot(timeUse)
plt.ylabel("time")
plt.show()
return timeUse;
and
print loopKeyValues(1000)
This function return me an error message for HashValue:
redis.exceptions.ResponseError: WRONGTYPE Operation against a key holding the wrong kind of value
When I use set()-def instead of hset(), the program return me a nice time plot. What could be a problem here and what means the parameter value?