-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathObjectStorageInterface.php
More file actions
49 lines (42 loc) · 1.24 KB
/
ObjectStorageInterface.php
File metadata and controls
49 lines (42 loc) · 1.24 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
<?php
declare(strict_types=1);
namespace TheCodingMachine\TDBM;
/**
* Object in charge of referencing all beans that have been fetched from the database.
* If a bean is requested twice from TDBM, the ObjectStorage is used to "cache" the bean.
*
* @author David Negrier
*/
interface ObjectStorageInterface
{
/**
* Sets an object in the storage.
*
* @param string $tableName
* @param string|int $id
* @param DbRow $dbRow
*/
public function set(string $tableName, $id, DbRow $dbRow): void;
// Notice: the interface has no "has" method because it is meaningless in the case of the Weakref implementation.
// See https://github.com/thecodingmachine/tdbm/pull/80#issuecomment-385902994
/**
* Returns an object from the storage (or null if no object is set).
*
* @param string $tableName
* @param string|int $id
*
* @return DbRow|null
*/
public function get(string $tableName, $id): ?DbRow;
/**
* Removes an object from the storage.
*
* @param string $tableName
* @param string|int $id
*/
public function remove(string $tableName, $id): void;
/**
* Removes all objects from the storage.
*/
public function clear(): void;
}