forked from parse-community/parse-php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParseMemoryStorage.php
More file actions
100 lines (91 loc) · 1.79 KB
/
Copy pathParseMemoryStorage.php
File metadata and controls
100 lines (91 loc) · 1.79 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* Class ParseMemoryStorage | Parse/ParseMemoryStorage.php
*/
namespace Parse;
/**
* Class ParseMemoryStorage - Uses non-persisted memory for storage.
* This is used by default if a PHP Session is not active.
*
* @author Fosco Marotto <fjm@fb.com>
* @package Parse
*/
class ParseMemoryStorage implements ParseStorageInterface
{
/**
* Memory storage
*
* @var array
*/
private $storage = [];
/**
* Sets a key-value pair in storage.
*
* @param string $key The key to set
* @param mixed $value The value to set
*
* @return void
*/
public function set($key, $value)
{
$this->storage[$key] = $value;
}
/**
* Remove a key from storage.
*
* @param string $key The key to remove.
*
* @return void
*/
public function remove($key)
{
unset($this->storage[$key]);
}
/**
* Gets the value for a key from storage.
*
* @param string $key The key to get the value for
*
* @return mixed
*/
public function get($key)
{
if (isset($this->storage[$key])) {
return $this->storage[$key];
}
return null;
}
/**
* Clear all the values in storage.
*/
public function clear()
{
$this->storage = [];
}
/**
* Save the data, if necessary. Not implemented.
*/
public function save()
{
// No action required.
return;
}
/**
* Get all keys in storage.
*
* @return array
*/
public function getKeys()
{
return array_keys($this->storage);
}
/**
* Get all key-value pairs from storage.
*
* @return array
*/
public function getAll()
{
return $this->storage;
}
}