Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Complex data structures Redis

Tags:

redis

Lets say I have a hash of a hash e.g.

$data = {     'harry' : {          'age' : 25,          'weight' : 75,     },     'sally' : {         'age' : 25,         'weight' : 75,     } } 
  1. What would the 'usual' way to store such a data structure (or would you not?)
  2. Would you be able to directly get a value (e.g. get harry : age ?
  3. Once stored could you directly change the value of a sub key (e.g. sally : weight = 100)
like image 782
Xrender Avatar asked Jan 10 '12 20:01

Xrender


People also ask

Can Redis handle big data?

Redis has many use cases for big data scenarios – primarily advanced by its extreme performance, simplicity and above all, versatility. High-Speed Data Ingest: Big data is characterized by its volume, variety and velocity.

Can Redis store arrays?

We use various data structures (linked lists, arrays, hashes, etc) in our applications.

What data types does Redis use to store a geospatial objects?

Redis lacks dedicated data types for geospatial objects. Instead, points are stored in sorted sets. The scores of the sets are used for encoding coordinate pairs.


1 Answers

What would the 'usual' way to store such a data structure (or would you not?)

For example harry and sally would be stored each in separate hashes where fields would represent their properties like age and weight. Then set structure would hold all the members (harry, sally, ...) which you have stored in redis.

Would you be able to directly get a value (e.g. get harry : age ?)

Yes, see HGET or HMGET or HGETALL.

Once stored could you directly change the value of a sub key (e.g. sally : weight = 100)

Yes, see HSET.

like image 131
yojimbo87 Avatar answered Sep 17 '22 12:09

yojimbo87