File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ final class FileRepository implements Repository
6
6
{
7
7
private $ filename ;
8
8
private $ identifier ;
9
+ private $ cache ;
9
10
10
11
public function __construct ($ filename , ObjectIdentifier $ identifier )
11
12
{
@@ -63,13 +64,18 @@ private function stringify($object)
63
64
64
65
private function loadDb ()
65
66
{
66
- return file_exists ($ this ->filename )
67
- ? unserialize (file_get_contents ($ this ->filename ))
68
- : [];
67
+ if (null === $ this ->cache ) {
68
+ $ this ->cache = file_exists ($ this ->filename )
69
+ ? unserialize (file_get_contents ($ this ->filename ))
70
+ : [];
71
+ }
72
+
73
+ return $ this ->cache ;
69
74
}
70
75
71
76
private function saveDb (array $ collection )
72
77
{
73
78
file_put_contents ($ this ->filename , serialize ($ collection ));
79
+ $ this ->cache = null ;
74
80
}
75
81
}
You can’t perform that action at this time.
0 commit comments