I have a class, which is modeled like this, all member variables are comprising of strings and integers.
> class XYZ extends CFormModel
{
//Values required for rendering the Dashboard
public $username;
public $analysis_type;
public $trace_selection;
public $filter_phantoms;
public $trace_oui_map;
public $frame_min;
public $frame_max;
public $time_end;
public $frame_range;
public $time_range;
//Other Values
private $RETURNURL;
private $PARAMS;
private $connection; // connection to db client
private $database; // handle to database
private $col_trace_info; // handle to trace_info collection
private $col_csv; // handle to csv collection
...
...
I want to store this object of this class in redis cache for performance improvements. Solutions i have stumbled upon to is to use hashmaps..
Yii::app()->cache()->executeCommand("HSET", array("KEY"=>$hashMap, "FIELD"=>$key, "VALUE"=>$object));
My question is, is there a better way to store is object in memory, by using any other data structure or serialize it before storing, or something like that??
Hash Sets are not needed (nor preferred), if you need the complete object or record at retrieval in most of your scenario's. A Hash Set is like a mini-redis database inside Redis. Each key has overhead, and each member of a Hash Set has overhead.
I recommend this approach:
\t
is normally a good one) and use the new function ZRANGEBYLEX
.See also here and here
Hope this helps, TW
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With