Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • DevNullStorage
  • FileJournal
  • FileStorage
  • MemcachedStorage
  • MemoryStorage
  • NewMemcachedStorage
  • PhpFileStorage
  • SQLiteStorage

Interfaces

  • IJournal
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (https://nette.org)
 5:  * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette\Caching\Storages;
 9: 
10: use Nette;
11: 
12: 
13: /**
14:  * Memory cache storage.
15:  */
16: class MemoryStorage extends Nette\Object implements Nette\Caching\IStorage
17: {
18:     /** @var array */
19:     private $data = array();
20: 
21: 
22:     /**
23:      * Read from cache.
24:      * @param  string key
25:      * @return mixed|NULL
26:      */
27:     public function read($key)
28:     {
29:         return isset($this->data[$key]) ? $this->data[$key] : NULL;
30:     }
31: 
32: 
33:     /**
34:      * Prevents item reading and writing. Lock is released by write() or remove().
35:      * @param  string key
36:      * @return void
37:      */
38:     public function lock($key)
39:     {
40:     }
41: 
42: 
43:     /**
44:      * Writes item into the cache.
45:      * @param  string key
46:      * @param  mixed  data
47:      * @param  array  dependencies
48:      * @return void
49:      */
50:     public function write($key, $data, array $dependencies)
51:     {
52:         $this->data[$key] = $data;
53:     }
54: 
55: 
56:     /**
57:      * Removes item from the cache.
58:      * @param  string key
59:      * @return void
60:      */
61:     public function remove($key)
62:     {
63:         unset($this->data[$key]);
64:     }
65: 
66: 
67:     /**
68:      * Removes items from the cache by conditions & garbage collector.
69:      * @param  array  conditions
70:      * @return void
71:      */
72:     public function clean(array $conditions)
73:     {
74:         if (!empty($conditions[Nette\Caching\Cache::ALL])) {
75:             $this->data = array();
76:         }
77:     }
78: 
79: }
80: 
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0