@@ -40,7 +40,7 @@ public function __construct(\Memcached $cache)
40
40
41
41
protected function fetchObjectFromCache ($ key )
42
42
{
43
- return $ this ->cache ->get ($ this ->getHierarchyKey ($ key ));
43
+ return $ this ->cache ->get ($ this ->trimKey ( $ this -> getHierarchyKey ($ key) ));
44
44
}
45
45
46
46
protected function clearAllObjectsFromCache ()
@@ -51,8 +51,8 @@ protected function clearAllObjectsFromCache()
51
51
protected function clearOneObjectFromCache ($ key )
52
52
{
53
53
$ this ->commit ();
54
- $ key = $ this ->getHierarchyKey ($ key , $ path );
55
- $ this ->cache ->increment ($ path , 1 , 0 );
54
+ $ key = $ this ->trimKey ( $ this -> getHierarchyKey ($ key , $ path) );
55
+ $ this ->cache ->increment ($ this -> trimKey ( $ path) , 1 , 0 );
56
56
$ this ->clearHierarchyKeyCache ();
57
57
58
58
if ($ this ->cache ->delete ($ key )) {
@@ -69,13 +69,28 @@ protected function storeItemInCache($key, CacheItemInterface $item, $ttl)
69
69
$ ttl = 0 ;
70
70
}
71
71
72
- $ key = $ this ->getHierarchyKey ($ key );
72
+ $ key = $ this ->trimKey ( $ this -> getHierarchyKey ($ key) );
73
73
74
74
return $ this ->cache ->set ($ key , $ item , $ ttl );
75
75
}
76
76
77
77
protected function getValueFormStore ($ key )
78
78
{
79
- return $ this ->cache ->get ($ key );
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 );
80
95
}
81
96
}
0 commit comments