Repository navigation
Expand file tree
/
Copy pathBaseCache.php
More file actions
65 lines (50 loc) · 1.66 KB
/
Copy pathBaseCache.php
File metadata and controls
65 lines (50 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace ccxt\pro;
use SplDoublyLinkedList;
class BaseCache implements \JsonSerializable, \ArrayAccess, \IteratorAggregate, \Countable {
public $max_size;
public $deque;
public function __construct($max_size = null) {
$this->max_size = $max_size;
// the deque implemented in Ds has fast shifting by using doubly linked lists
// https://www.php.net/manual/en/class.ds-deque.php
// would inherit directly but it is marked as final
$this->deque = array();
// default mode
// $this->deque->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP);
}
public function getIterator() : \Traversable {
return new \ArrayObject($this->deque);
}
public function JsonSerialize() : array {
return $this->deque;
}
public function count() : int {
return count($this->deque);
}
public function clear() {
$this->deque = array();
}
public function &offsetGet($offset) : mixed {
return $this->deque[$offset];
}
public function offsetSet($index, $newval) : void {
$this->deque[$index] = $newval;
}
public function offsetExists($index) : bool {
return $index < $this->count();
}
public function offsetUnset($index) : void {
unset($this->deque[$index]);
}
public function __toString() {
return print_r($this->deque, true);
}
// meant to be overriden
public function getLimit($symbol, $limit) {
}
// support transpiled snake_case calls
public function get_limit($symbol, $limit) {
return $this->getLimit($symbol, $limit);
}
}