7
7
8
8
namespace Nette \Caching \Storages ;
9
9
10
- use Nette ,
11
- Nette \Caching \Cache ;
10
+ use Nette ;
11
+ use Nette \Caching \Cache ;
12
12
13
13
14
14
/**
@@ -22,13 +22,13 @@ class FileJournal extends Nette\Object implements IJournal
22
22
const FILE = 'btfj.dat ' ;
23
23
24
24
/** 4 bytes file header magic (btfj) */
25
- const FILE_MAGIC = 0x6274666A ;
25
+ const FILE_MAGIC = 0x6274666A ;
26
26
27
27
/** 4 bytes index node magic (inde) */
28
28
const INDEX_MAGIC = 0x696E6465 ;
29
29
30
30
/** 4 bytes data node magic (data) */
31
- const DATA_MAGIC = 0x64617461 ;
31
+ const DATA_MAGIC = 0x64617461 ;
32
32
33
33
/** Node size in bytes */
34
34
const NODE_SIZE = 4096 ;
@@ -40,7 +40,7 @@ class FileJournal extends Nette\Object implements IJournal
40
40
const HEADER_SIZE = 4096 ;
41
41
42
42
/** Size of 32 bit integer in bytes. INT32_SIZE = 32 / 8 :-) */
43
- const INT32_SIZE = 4 ;
43
+ const INT32_SIZE = 4 ;
44
44
45
45
const INFO = 'i ' ,
46
46
TYPE = 't ' , // TAGS, PRIORITY or DATA
@@ -92,10 +92,10 @@ class FileJournal extends Nette\Object implements IJournal
92
92
93
93
/** @var array */
94
94
private static $ startNode = array (
95
- self ::TAGS => 0 ,
95
+ self ::TAGS => 0 ,
96
96
self ::PRIORITY => 1 ,
97
- self ::ENTRIES => 2 ,
98
- self ::DATA => 3 ,
97
+ self ::ENTRIES => 2 ,
98
+ self ::DATA => 3 ,
99
99
);
100
100
101
101
@@ -190,7 +190,7 @@ public function write($key, array $dependencies)
190
190
self ::INFO => array (
191
191
self ::LAST_INDEX => ($ freeDataNode << self ::BITROT ),
192
192
self ::TYPE => self ::DATA ,
193
- )
193
+ ),
194
194
);
195
195
}
196
196
@@ -249,7 +249,7 @@ public function clean(array $conditions)
249
249
$ toDelete = array (
250
250
self ::TAGS => array (),
251
251
self ::PRIORITY => array (),
252
- self ::ENTRIES => array ()
252
+ self ::ENTRIES => array (),
253
253
);
254
254
255
255
$ entries = array ();
@@ -297,7 +297,7 @@ private function cleanTags(array $tags, array & $toDelete)
297
297
298
298
/**
299
299
* Cleans entries from journal by priority.
300
- * @param integer
300
+ * @param int
301
301
* @param array
302
302
* @return array of removed items
303
303
*/
@@ -560,7 +560,7 @@ private function cleanIndexData($nextNodeId, array $links, & $masterNodeLink)
560
560
561
561
/**
562
562
* Get node from journal.
563
- * @param integer
563
+ * @param int
564
564
* @return array
565
565
*/
566
566
private function getNode ($ id )
@@ -606,7 +606,7 @@ private function getNode($id)
606
606
607
607
/**
608
608
* Save node to cache.
609
- * @param integer
609
+ * @param int
610
610
* @param array
611
611
* @return void
612
612
*/
@@ -706,7 +706,7 @@ private function commit()
706
706
707
707
/**
708
708
* Prepare node to journal file structure.
709
- * @param integer
709
+ * @param int
710
710
* @param array|bool
711
711
* @return bool Successfully committed
712
712
*/
@@ -750,7 +750,7 @@ private function prepareNode($id, $node)
750
750
751
751
/**
752
752
* Commit node string to journal file.
753
- * @param integer
753
+ * @param int
754
754
* @param string
755
755
* @return void
756
756
*/
@@ -788,7 +788,7 @@ private function findIndexNode($type, $search, $childId = NULL, $prevId = NULL)
788
788
self ::PREV_NODE => -1 ,
789
789
self ::END => -1 ,
790
790
self ::MAX => -1 ,
791
- )
791
+ ),
792
792
),
793
793
$ parentId ,
794
794
); // Init empty node
@@ -818,8 +818,8 @@ private function findIndexNode($type, $search, $childId = NULL, $prevId = NULL)
818
818
819
819
/**
820
820
* Find complete free node.
821
- * @param integer
822
- * @return array|integer Node ID
821
+ * @param int
822
+ * @return array|int Node ID
823
823
*/
824
824
private function findFreeNode ($ count = 1 )
825
825
{
@@ -858,8 +858,8 @@ private function findFreeNode($count = 1)
858
858
859
859
/**
860
860
* Find free data node that has $size bytes of free space.
861
- * @param integer size in bytes
862
- * @return integer Node ID
861
+ * @param int size in bytes
862
+ * @return int Node ID
863
863
*/
864
864
private function findFreeDataNode ($ size )
865
865
{
@@ -904,7 +904,7 @@ private function findFreeDataNode($size)
904
904
905
905
/**
906
906
* Bisect node or when has only one key, move part to data node.
907
- * @param integer Node ID
907
+ * @param int Node ID
908
908
* @param array Node
909
909
* @return void
910
910
*/
@@ -993,7 +993,7 @@ private function bisectNode($id, array $node)
993
993
);
994
994
$ this ->saveNode ($ id , $ second );
995
995
996
- list (,, $ parent ) = $ this ->findIndexNode ($ nodeInfo [self ::TYPE ], $ halfKey );
996
+ list (, , $ parent ) = $ this ->findIndexNode ($ nodeInfo [self ::TYPE ], $ halfKey );
997
997
$ parentNode = $ this ->getNode ($ parent );
998
998
if ($ parentNode === FALSE ) {
999
999
if (self ::$ debug ) {
@@ -1021,7 +1021,7 @@ private function headerCommit()
1021
1021
1022
1022
/**
1023
1023
* Remove node from journal file.
1024
- * @param integer
1024
+ * @param int
1025
1025
* @return void
1026
1026
*/
1027
1027
private function deleteNode ($ id )
@@ -1087,7 +1087,7 @@ private function lock()
1087
1087
1088
1088
1089
1089
/**
1090
- * Open btfj.dat file (or create it if not exists) and load metainformation
1090
+ * Open btfj.dat file (or create it if not exists) and load metainformation.
1091
1091
* @throws Nette\InvalidStateException
1092
1092
*/
1093
1093
private function prepare ()
@@ -1104,7 +1104,7 @@ private function prepare()
1104
1104
$ written = fwrite ($ init , pack ('N2 ' , self ::FILE_MAGIC , $ this ->lastNode ));
1105
1105
fclose ($ init );
1106
1106
if ($ written !== self ::INT32_SIZE * 2 ) {
1107
- throw new Nette \InvalidStateException (" Cannot write journal header. " );
1107
+ throw new Nette \InvalidStateException (' Cannot write journal header. ' );
1108
1108
}
1109
1109
}
1110
1110
}
@@ -1149,8 +1149,7 @@ private function unlock()
1149
1149
1150
1150
1151
1151
/**
1152
- * @param int $nodeId
1153
- * @param array $nodeData
1152
+ * @param int
1154
1153
* @return int
1155
1154
* @throws Nette\InvalidStateException
1156
1155
*/
@@ -1175,7 +1174,7 @@ private function findNextFreeKey($nodeId, array & $nodeData)
1175
1174
1176
1175
/**
1177
1176
* Append $append to $array.
1178
- * This function is much faster then $array = array_merge($array, $append)
1177
+ * This function is much faster than $array = array_merge($array, $append)
1179
1178
* @param array
1180
1179
* @param array
1181
1180
* @return void
@@ -1190,7 +1189,7 @@ private function arrayAppend(array & $array, array $append)
1190
1189
1191
1190
/**
1192
1191
* Append $append to $array with preserve keys.
1193
- * This function is much faster then $array = $array + $append
1192
+ * This function is much faster than $array = $array + $append
1194
1193
* @param array
1195
1194
* @param array
1196
1195
* @return void
@@ -1201,4 +1200,5 @@ private function arrayAppendKeys(array & $array, array $append)
1201
1200
$ array [$ key ] = $ value ;
1202
1201
}
1203
1202
}
1203
+
1204
1204
}
0 commit comments