@@ -37,6 +37,20 @@ public function __construct(Store $store, string $prefix = 'rollout')
37
37
$ this ->prefix = $ prefix ;
38
38
}
39
39
40
+ /**
41
+ * Prepends our key with the configured prefix.
42
+ *
43
+ * @param string $key
44
+ * The key to prepend with the prefix.
45
+ *
46
+ * @return string
47
+ * The prefixed key.
48
+ */
49
+ private function prefixKey ($ key ) : string
50
+ {
51
+ return sprintf ('%s.%s ' , $ this ->prefix , $ key );
52
+ }
53
+
40
54
/**
41
55
* Get's the value corresponding to the provided key from the cache. Note
42
56
* this function has the side effect of prepending the local prefix to the
@@ -50,8 +64,7 @@ public function __construct(Store $store, string $prefix = 'rollout')
50
64
*/
51
65
public function get ($ key )
52
66
{
53
- $ key = sprintf ('%s.%s ' , $ this ->prefix , $ key );
54
- return $ this ->store ->get ($ key , null );
67
+ return $ this ->store ->get ($ this ->prefixKey ($ key ), null );
55
68
}
56
69
57
70
/**
@@ -67,8 +80,7 @@ public function get($key)
67
80
*/
68
81
public function set ($ key , $ value )
69
82
{
70
- $ key = sprintf ('%s.%s ' , $ this ->prefix , $ key );
71
- $ this ->store ->forever ($ key , $ value );
83
+ $ this ->store ->forever ($ this ->prefixKey ($ key ), $ value );
72
84
}
73
85
74
86
/**
@@ -82,7 +94,6 @@ public function set($key, $value)
82
94
*/
83
95
public function remove ($ key )
84
96
{
85
- $ key = sprintf ('%s.%s ' , $ this ->prefix , $ key );
86
- $ this ->store ->forget ($ key );
97
+ $ this ->store ->forget ($ this ->prefixKey ($ key ));
87
98
}
88
99
}
0 commit comments