@@ -40,7 +40,11 @@ public function __construct(\Memcached $cache)
40
40
41
41
protected function fetchObjectFromCache ($ key )
42
42
{
43
- return $ this ->cache ->get ($ this ->trimKey ($ this ->getHierarchyKey ($ key )));
43
+ if (false === $ result = unserialize ($ this ->cache ->get ($ this ->getHierarchyKey ($ key )))) {
44
+ return [false , null ];
45
+ }
46
+
47
+ return $ result ;
44
48
}
45
49
46
50
protected function clearAllObjectsFromCache ()
@@ -51,8 +55,8 @@ protected function clearAllObjectsFromCache()
51
55
protected function clearOneObjectFromCache ($ key )
52
56
{
53
57
$ this ->commit ();
54
- $ key = $ this ->trimKey ( $ this -> getHierarchyKey ($ key , $ path) );
55
- $ this ->cache ->increment ($ this -> trimKey ( $ path) , 1 , 0 );
58
+ $ key = $ this ->getHierarchyKey ($ key , $ path );
59
+ $ this ->cache ->increment ($ path , 1 , 0 );
56
60
$ this ->clearHierarchyKeyCache ();
57
61
58
62
if ($ this ->cache ->delete ($ key )) {
@@ -69,28 +73,13 @@ protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
69
73
$ ttl = 0 ;
70
74
}
71
75
72
- $ key = $ this ->trimKey ( $ this -> getHierarchyKey ($ key) );
76
+ $ key = $ this ->getHierarchyKey ($ key );
73
77
74
- return $ this ->cache ->set ($ key , $ item , $ ttl );
78
+ return $ this ->cache ->set ($ key , serialize ([ true , $ item-> get ()]) , $ ttl );
75
79
}
76
80
77
81
protected function getValueFormStore ($ key )
78
82
{
79
- return $ this ->cache ->get ($ this ->trimKey ($ key ));
80
- }
81
-
82
- /**
83
- * Calculate a key. If it is more than 250 chars we should hash the key.
84
- *
85
- * @param $key
86
- * @param null $ref
87
- */
88
- private function trimKey ($ key )
89
- {
90
- if (strlen ($ key ) < 250 ) {
91
- return $ key ;
92
- }
93
- // This should maybe be logged
94
- return sha1 ($ key );
83
+ return $ this ->cache ->get ($ key );
95
84
}
96
85
}
0 commit comments