ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Memory.php
Go to the documentation of this file.
1<?php
2
9{
13 protected $definitions;
14
18 public $name = 'Memory';
19
23 public function copy()
24 {
26 }
27
33 public function add($def, $config)
34 {
35 $status = parent::add($def, $config);
36 if ($status) {
37 $this->definitions[$this->generateKey($config)] = $def;
38 }
39 return $status;
40 }
41
47 public function set($def, $config)
48 {
49 $status = parent::set($def, $config);
50 if ($status) {
51 $this->definitions[$this->generateKey($config)] = $def;
52 }
53 return $status;
54 }
55
61 public function replace($def, $config)
62 {
63 $status = parent::replace($def, $config);
64 if ($status) {
65 $this->definitions[$this->generateKey($config)] = $def;
66 }
67 return $status;
68 }
69
74 public function get($config)
75 {
76 $key = $this->generateKey($config);
77 if (isset($this->definitions[$key])) {
78 return $this->definitions[$key];
79 }
80 $this->definitions[$key] = parent::get($config);
81 return $this->definitions[$key];
82 }
83}
84
85// vim: et sw=4 sts=4
Definition cache decorator class that saves all cache retrievals to PHP's memory; good for unit tests...
Definition: Memory.php:9
generateKey($config)
Generates a unique identifier for a particular configuration.