---
title: "Phalcon Storage"
version: "5.20"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.phalcon.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Phalcon Storage

:::info[NOTE]
All classes are prefixed with `Phalcon`
:::

## Storage\AdapterFactory

Class

- [`Phalcon\Factory\AbstractConfigFactory`](/5.20/api/phalcon_factory/#factoryabstractconfigfactory)
- [`Phalcon\Factory\AbstractFactory`](/5.20/api/phalcon_factory/#factoryabstractfactory)
- **`Phalcon\Storage\AdapterFactory`**

`Exception` · `Phalcon\Contracts\Storage\StorageTypes` · `Phalcon\Factory\AbstractFactory` · `Phalcon\Storage\Adapter\AdapterInterface` · `Phalcon\Storage\Adapter\Apcu` · `Phalcon\Storage\Adapter\Libmemcached` · `Phalcon\Storage\Adapter\Memory` · `Phalcon\Storage\Adapter\Redis` · `Phalcon\Storage\Adapter\RedisCluster` · `Phalcon\Storage\Adapter\Stream` · `Phalcon\Storage\Adapter\Weak` · `Throwable`

### Method Summary

<ApiItem href="#storageadapterfactory-__construct" visibility="public" name="__construct" returnType="" params={[{"type":"SerializerFactory","name":"factory","default":null},{"type":"array","name":"services","default":"[]"}]}>
AdapterFactory constructor.
</ApiItem>
<ApiItem href="#storageadapterfactory-newinstance" visibility="public" name="newInstance" returnType="AdapterInterface" params={[{"type":"string","name":"name","default":null},{"type":"array","name":"options","default":"[]"}]}>
Create a new instance of the adapter
</ApiItem>
<ApiItem href="#storageadapterfactory-getexceptionclass" visibility="protected" name="getExceptionClass" returnType="string" params={[]}>
</ApiItem>
<ApiItem href="#storageadapterfactory-getservices" visibility="protected" name="getServices" returnType="array" params={[]}>
Returns the available adapters
</ApiItem>

### Methods

<h4 id="storageadapterfactory-__construct"><code>__construct()</code></h4>

```php
public function __construct(
SerializerFactory $factory,
array $services = []
);
```

AdapterFactory constructor.

<h4 id="storageadapterfactory-newinstance"><code>newInstance()</code></h4>

```php
public function newInstance(
string $name,
array $options = []
): AdapterInterface;
```

Create a new instance of the adapter

<h4 id="storageadapterfactory-getexceptionclass"><code>getExceptionClass()</code></h4>

```php
protected function getExceptionClass(): string;
```

<h4 id="storageadapterfactory-getservices"><code>getServices()</code></h4>

```php
protected function getServices(): array;
```

Returns the available adapters

## Storage\Adapter\AbstractAdapter

Abstract

Storage AbstractAdapter

- **`Phalcon\Storage\Adapter\AbstractAdapter`** - implements [`Phalcon\Storage\Adapter\AdapterInterface`](#storageadapteradapterinterface), [`Phalcon\Events\EventsAwareInterface`](/5.20/api/phalcon_events/#eventseventsawareinterface)
- [`Phalcon\Storage\Adapter\Apcu`](#storageadapterapcu)
- [`Phalcon\Storage\Adapter\Libmemcached`](#storageadapterlibmemcached)
- [`Phalcon\Storage\Adapter\Memory`](#storageadaptermemory)
- [`Phalcon\Storage\Adapter\Redis`](#storageadapterredis)
- [`Phalcon\Storage\Adapter\Stream`](#storageadapterstream)
- [`Phalcon\Storage\Adapter\Weak`](#storageadapterweak)

`DateInterval` · `DateTime` · `Exception` · `Phalcon\Contracts\Storage\StorageTypes` · `Phalcon\Events\EventsAwareInterface` · `Phalcon\Events\ManagerInterface` · `Phalcon\Events\Traits\EventsAwareTrait` · `Phalcon\Storage\SerializerFactory` · `Phalcon\Storage\Serializer\SerializerInterface` · `Phalcon\Traits\Support\Helper\Arr\GetTrait`

### Method Summary

<ApiItem href="#storageadapterabstractadapter-clear" visibility="public" name="clear" returnType="bool" params={[]}>
Flushes/clears the cache
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-decrement" visibility="public" name="decrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Decrements a stored number
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-delete" visibility="public" name="delete" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Deletes data from the adapter
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-deletemultiple" visibility="public" name="deleteMultiple" returnType="bool" params={[{"type":"array","name":"keys","default":null}]}>
Deletes multiple data from the adapter
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-get" visibility="public" name="get" returnType="mixed" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"defaultValue","default":"null"}]}>
Reads data from the adapter
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-getadapter" visibility="public" name="getAdapter" returnType="mixed" params={[]}>
Returns the adapter - connects to the storage if not connected
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-getdefaultserializer" visibility="public" name="getDefaultSerializer" returnType="string" params={[]}>
Name of the default serializer class
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-getkeys" visibility="public" name="getKeys" returnType="array" params={[{"type":"string","name":"prefix","default":"\"\""}]}>
Returns all the keys stored
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-getlifetime" visibility="public" name="getLifetime" returnType="int" params={[]}>
Returns the lifetime
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-getprefix" visibility="public" name="getPrefix" returnType="string" params={[]}>
Returns the prefix
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-getserializer" visibility="public" name="getSerializer" returnType="SerializerInterface|null" params={[]}>
Get the serializer
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-has" visibility="public" name="has" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Checks if an element exists in the cache
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-increment" visibility="public" name="increment" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Increments a stored number
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-set" visibility="public" name="set" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"value","default":null},{"type":"mixed","name":"ttl","default":"null"}]}>
Stores data in the adapter. If the TTL is `null` (default) or not defined
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-setdefaultserializer" visibility="public" name="setDefaultSerializer" returnType="void" params={[{"type":"string","name":"serializer","default":null}]}>
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-__construct" visibility="protected" name="__construct" returnType="" params={[{"type":"SerializerFactory","name":"serializerFactory","default":null},{"type":"array","name":"options","default":"[]"}]}>
AbstractAdapter constructor.
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-dodecrement" visibility="protected" name="doDecrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Decrements a stored number
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-dodelete" visibility="protected" name="doDelete" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Deletes data from the adapter
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-dodeletemultiple" visibility="protected" name="doDeleteMultiple" returnType="bool" params={[{"type":"array","name":"keys","default":null}]}>
Deletes multiple data from the adapter
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-doget" visibility="protected" name="doGet" returnType="mixed" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"defaultValue","default":"null"}]}>
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-dogetdata" visibility="protected" name="doGetData" returnType="mixed" params={[{"type":"string","name":"key","default":null}]}>
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-dohas" visibility="protected" name="doHas" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Checks if an element exists in the cache
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-doincrement" visibility="protected" name="doIncrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Increments a stored number
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-doset" visibility="protected" name="doSet" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"value","default":null},{"type":"mixed","name":"ttl","default":"null"}]}>
Stores data in the adapter. If the TTL is `null` (default) or not defined
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-getfilteredkeys" visibility="protected" name="getFilteredKeys" returnType="array" params={[{"type":"mixed","name":"keys","default":null},{"type":"string","name":"prefix","default":null}]}>
Filters the keys array based on global and passed prefix
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-getkeywithoutprefix" visibility="protected" name="getKeyWithoutPrefix" returnType="string" params={[{"type":"string","name":"key","default":null}]}>
Check if the key has the prefix and remove it, otherwise just return the
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-getprefixedkey" visibility="protected" name="getPrefixedKey" returnType="string" params={[{"type":"mixed","name":"key","default":null}]}>
Returns the key requested, prefixed
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-getserializeddata" visibility="protected" name="getSerializedData" returnType="mixed" params={[{"type":"mixed","name":"content","default":null}]}>
Returns serialized data
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-getttl" visibility="protected" name="getTtl" returnType="int" params={[{"type":"mixed","name":"ttl","default":null}]}>
Calculates the TTL for a cache item
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-getunserializeddata" visibility="protected" name="getUnserializedData" returnType="mixed" params={[{"type":"mixed","name":"content","default":null},{"type":"mixed","name":"defaultValue","default":"null"}]}>
Returns unserialized data
</ApiItem>
<ApiItem href="#storageadapterabstractadapter-initserializer" visibility="protected" name="initSerializer" returnType="void" params={[]}>
Initializes the serializer
</ApiItem>

### Properties

<ApiItem kind="property" visibility="protected" name="adapter" type="mixed" default="">
</ApiItem>
<ApiItem kind="property" visibility="protected" name="allowedClasses" type="bool|array&lt;int, string&gt;" default="true">
Classes the "php" serializer may instantiate: true, false or a list
of class names (the "allowedClasses" option)
</ApiItem>
<ApiItem kind="property" visibility="protected" name="defaultSerializer" type="string" default="&quot;php&quot;">
Name of the default serializer class
</ApiItem>
<ApiItem kind="property" visibility="protected" name="eventType" type="string" default="&quot;storage&quot;">
EventType prefix.
</ApiItem>
<ApiItem kind="property" visibility="protected" name="lifetime" type="int" default="3600">
Name of the default TTL (time to live)
</ApiItem>
<ApiItem kind="property" visibility="protected" name="options" type="array&lt;string, mixed&gt;" default="[]">
</ApiItem>
<ApiItem kind="property" visibility="protected" name="prefix" type="string" default="&quot;ph-memo-&quot;">
</ApiItem>
<ApiItem kind="property" visibility="protected" name="serializer" type="SerializerInterface|null" default="null">
</ApiItem>
<ApiItem kind="property" visibility="protected" name="serializerFactory" type="SerializerFactory" default="">
</ApiItem>
<ApiItem kind="property" visibility="protected" name="stripPrefix" type="bool" default="true">
Whether a leading prefix is stripped from incoming keys before the
adapter prefix is applied. Disable when keys are externally
generated identifiers that may legitimately start with the prefix
text (e.g. session ids).
</ApiItem>

### Methods

<h4 id="storageadapterabstractadapter-clear"><code>clear()</code></h4>

```php
abstract public function clear(): bool;
```

Flushes/clears the cache

<h4 id="storageadapterabstractadapter-decrement"><code>decrement()</code></h4>

```php
public function decrement(
string $key,
int $value = 1
): false|int;
```

Decrements a stored number

<h4 id="storageadapterabstractadapter-delete"><code>delete()</code></h4>

```php
public function delete( string $key ): bool;
```

Deletes data from the adapter

<h4 id="storageadapterabstractadapter-deletemultiple"><code>deleteMultiple()</code></h4>

```php
public function deleteMultiple( array $keys ): bool;
```

Deletes multiple data from the adapter

<h4 id="storageadapterabstractadapter-get"><code>get()</code></h4>

```php
public function get(
string $key,
mixed $defaultValue = null
): mixed;
```

Reads data from the adapter

<h4 id="storageadapterabstractadapter-getadapter"><code>getAdapter()</code></h4>

```php
public function getAdapter(): mixed;
```

Returns the adapter - connects to the storage if not connected

<h4 id="storageadapterabstractadapter-getdefaultserializer"><code>getDefaultSerializer()</code></h4>

```php
public function getDefaultSerializer(): string;
```

Name of the default serializer class

<h4 id="storageadapterabstractadapter-getkeys"><code>getKeys()</code></h4>

```php
abstract public function getKeys( string $prefix = "" ): array;
```

Returns all the keys stored

<h4 id="storageadapterabstractadapter-getlifetime"><code>getLifetime()</code></h4>

```php
public function getLifetime(): int;
```

Returns the lifetime

<h4 id="storageadapterabstractadapter-getprefix"><code>getPrefix()</code></h4>

```php
public function getPrefix(): string;
```

Returns the prefix

<h4 id="storageadapterabstractadapter-getserializer"><code>getSerializer()</code></h4>

```php
public function getSerializer(): SerializerInterface|null;
```

Get the serializer

<h4 id="storageadapterabstractadapter-has"><code>has()</code></h4>

```php
public function has( string $key ): bool;
```

Checks if an element exists in the cache

<h4 id="storageadapterabstractadapter-increment"><code>increment()</code></h4>

```php
public function increment(
string $key,
int $value = 1
): false|int;
```

Increments a stored number

<h4 id="storageadapterabstractadapter-set"><code>set()</code></h4>

```php
public function set(
string $key,
mixed $value,
mixed $ttl = null
): bool;
```

Stores data in the adapter. If the TTL is `null` (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is `0` or a negative number, a `delete()` will be issued, since this
item has expired. If you need to set this key forever, you should use
the `setForever()` method.

<h4 id="storageadapterabstractadapter-setdefaultserializer"><code>setDefaultSerializer()</code></h4>

```php
public function setDefaultSerializer( string $serializer ): void;
```

<h4 id="storageadapterabstractadapter-__construct"><code>__construct()</code></h4>

```php
protected function __construct(
SerializerFactory $serializerFactory,
array $options = []
);
```

AbstractAdapter constructor.

<h4 id="storageadapterabstractadapter-dodecrement"><code>doDecrement()</code></h4>

```php
abstract protected function doDecrement(
string $key,
int $value = 1
): false|int;
```

Decrements a stored number

<h4 id="storageadapterabstractadapter-dodelete"><code>doDelete()</code></h4>

```php
abstract protected function doDelete( string $key ): bool;
```

Deletes data from the adapter

<h4 id="storageadapterabstractadapter-dodeletemultiple"><code>doDeleteMultiple()</code></h4>

```php
protected function doDeleteMultiple( array $keys ): bool;
```

Deletes multiple data from the adapter

<h4 id="storageadapterabstractadapter-doget"><code>doGet()</code></h4>

```php
protected function doGet(
string $key,
mixed $defaultValue = null
): mixed;
```

<h4 id="storageadapterabstractadapter-dogetdata"><code>doGetData()</code></h4>

```php
protected function doGetData( string $key ): mixed;
```

<h4 id="storageadapterabstractadapter-dohas"><code>doHas()</code></h4>

```php
abstract protected function doHas( string $key ): bool;
```

Checks if an element exists in the cache

<h4 id="storageadapterabstractadapter-doincrement"><code>doIncrement()</code></h4>

```php
abstract protected function doIncrement(
string $key,
int $value = 1
): false|int;
```

Increments a stored number

<h4 id="storageadapterabstractadapter-doset"><code>doSet()</code></h4>

```php
abstract protected function doSet(
string $key,
mixed $value,
mixed $ttl = null
): bool;
```

Stores data in the adapter. If the TTL is `null` (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is `0` or a negative number, a `delete()` will be issued, since this
item has expired. If you need to set this key forever, you should use
the `setForever()` method.

<h4 id="storageadapterabstractadapter-getfilteredkeys"><code>getFilteredKeys()</code></h4>

```php
protected function getFilteredKeys(
mixed $keys,
string $prefix
): array;
```

Filters the keys array based on global and passed prefix

<h4 id="storageadapterabstractadapter-getkeywithoutprefix"><code>getKeyWithoutPrefix()</code></h4>

```php
protected function getKeyWithoutPrefix( string $key ): string;
```

Check if the key has the prefix and remove it, otherwise just return the
key unaltered. When the `stripPrefix` option is `false` the key is
always returned unaltered.

<h4 id="storageadapterabstractadapter-getprefixedkey"><code>getPrefixedKey()</code></h4>

```php
protected function getPrefixedKey( mixed $key ): string;
```

Returns the key requested, prefixed

<h4 id="storageadapterabstractadapter-getserializeddata"><code>getSerializedData()</code></h4>

```php
protected function getSerializedData( mixed $content ): mixed;
```

Returns serialized data

<h4 id="storageadapterabstractadapter-getttl"><code>getTtl()</code></h4>

```php
protected function getTtl( mixed $ttl ): int;
```

Calculates the TTL for a cache item

<h4 id="storageadapterabstractadapter-getunserializeddata"><code>getUnserializedData()</code></h4>

```php
protected function getUnserializedData(
mixed $content,
mixed $defaultValue = null
): mixed;
```

Returns unserialized data

<h4 id="storageadapterabstractadapter-initserializer"><code>initSerializer()</code></h4>

```php
protected function initSerializer(): void;
```

Initializes the serializer

## Storage\Adapter\AdapterInterface

Interface

Interface for Phalcon\Logger adapters

- **`Phalcon\Storage\Adapter\AdapterInterface`**
- [`Phalcon\Cache\Adapter\AdapterInterface`](/5.20/api/phalcon_cache/#cacheadapteradapterinterface)

`DateInterval` · `Phalcon\Contracts\Storage\StorageTypes`

### Method Summary

<ApiItem href="#storageadapteradapterinterface-clear" visibility="public" name="clear" returnType="bool" params={[]}>
Flushes/clears the cache
</ApiItem>
<ApiItem href="#storageadapteradapterinterface-decrement" visibility="public" name="decrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Decrements a stored number
</ApiItem>
<ApiItem href="#storageadapteradapterinterface-delete" visibility="public" name="delete" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Deletes data from the adapter
</ApiItem>
<ApiItem href="#storageadapteradapterinterface-deletemultiple" visibility="public" name="deleteMultiple" returnType="bool" params={[{"type":"array","name":"keys","default":null}]}>
Deletes multiple data from the adapter
</ApiItem>
<ApiItem href="#storageadapteradapterinterface-get" visibility="public" name="get" returnType="mixed" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"defaultValue","default":"null"}]}>
Reads data from the adapter
</ApiItem>
<ApiItem href="#storageadapteradapterinterface-getadapter" visibility="public" name="getAdapter" returnType="mixed" params={[]}>
Returns the already connected adapter or connects to the backend
</ApiItem>
<ApiItem href="#storageadapteradapterinterface-getkeys" visibility="public" name="getKeys" returnType="array" params={[{"type":"string","name":"prefix","default":"\"\""}]}>
Returns all the keys stored
</ApiItem>
<ApiItem href="#storageadapteradapterinterface-getprefix" visibility="public" name="getPrefix" returnType="string" params={[]}>
Returns the prefix for the keys
</ApiItem>
<ApiItem href="#storageadapteradapterinterface-has" visibility="public" name="has" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Checks if an element exists in the cache
</ApiItem>
<ApiItem href="#storageadapteradapterinterface-increment" visibility="public" name="increment" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Increments a stored number
</ApiItem>
<ApiItem href="#storageadapteradapterinterface-set" visibility="public" name="set" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"value","default":null},{"type":"mixed","name":"ttl","default":"null"}]}>
Stores data in the adapter. If the TTL is `null` (default) or not defined
</ApiItem>
<ApiItem href="#storageadapteradapterinterface-setforever" visibility="public" name="setForever" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"data","default":null}]}>
Stores data in the adapter forever. The key needs to be manually deleted
</ApiItem>

### Methods

<h4 id="storageadapteradapterinterface-clear"><code>clear()</code></h4>

```php
public function clear(): bool;
```

Flushes/clears the cache

<h4 id="storageadapteradapterinterface-decrement"><code>decrement()</code></h4>

```php
public function decrement(
string $key,
int $value = 1
): false|int;
```

Decrements a stored number

<h4 id="storageadapteradapterinterface-delete"><code>delete()</code></h4>

```php
public function delete( string $key ): bool;
```

Deletes data from the adapter

<h4 id="storageadapteradapterinterface-deletemultiple"><code>deleteMultiple()</code></h4>

```php
public function deleteMultiple( array $keys ): bool;
```

Deletes multiple data from the adapter

<h4 id="storageadapteradapterinterface-get"><code>get()</code></h4>

```php
public function get(
string $key,
mixed $defaultValue = null
): mixed;
```

Reads data from the adapter

<h4 id="storageadapteradapterinterface-getadapter"><code>getAdapter()</code></h4>

```php
public function getAdapter(): mixed;
```

Returns the already connected adapter or connects to the backend
server(s)

<h4 id="storageadapteradapterinterface-getkeys"><code>getKeys()</code></h4>

```php
public function getKeys( string $prefix = "" ): array;
```

Returns all the keys stored

<h4 id="storageadapteradapterinterface-getprefix"><code>getPrefix()</code></h4>

```php
public function getPrefix(): string;
```

Returns the prefix for the keys

<h4 id="storageadapteradapterinterface-has"><code>has()</code></h4>

```php
public function has( string $key ): bool;
```

Checks if an element exists in the cache

<h4 id="storageadapteradapterinterface-increment"><code>increment()</code></h4>

```php
public function increment(
string $key,
int $value = 1
): false|int;
```

Increments a stored number

<h4 id="storageadapteradapterinterface-set"><code>set()</code></h4>

```php
public function set(
string $key,
mixed $value,
mixed $ttl = null
): bool;
```

Stores data in the adapter. If the TTL is `null` (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is `0` or a negative number, a `delete()` will be issued, since this
item has expired. If you need to set this key forever, you should use
the `setForever()` method.

<h4 id="storageadapteradapterinterface-setforever"><code>setForever()</code></h4>

```php
public function setForever(
string $key,
mixed $data
): bool;
```

Stores data in the adapter forever. The key needs to be manually deleted
from the adapter.

## Storage\Adapter\Apcu

Class

Apcu adapter

Capabilities:
- Counters: native atomic (apcu_inc()/apcu_dec()).
- getKeys(): APCUIterator regex scan over the shared APCu store.
- Serializers: Phalcon-side only; no backend-native serializer.

- [`Phalcon\Storage\Adapter\AbstractAdapter`](#storageadapterabstractadapter)
- **`Phalcon\Storage\Adapter\Apcu`**
- [`Phalcon\Cache\Adapter\Apcu`](/5.20/api/phalcon_cache/#cacheadapterapcu)

`APCUIterator` · `Exception` · `Phalcon\Contracts\Storage\StorageTypes` · `Phalcon\Storage\SerializerFactory` · `Phalcon\Traits\Php\ApcuTrait`

### Method Summary

<ApiItem href="#storageadapterapcu-__construct" visibility="public" name="__construct" returnType="" params={[{"type":"SerializerFactory","name":"factory","default":null},{"type":"array","name":"options","default":"[]"}]}>
Apcu constructor.
</ApiItem>
<ApiItem href="#storageadapterapcu-clear" visibility="public" name="clear" returnType="bool" params={[]}>
Flushes/clears the cache
</ApiItem>
<ApiItem href="#storageadapterapcu-getkeys" visibility="public" name="getKeys" returnType="array" params={[{"type":"string","name":"prefix","default":"\"\""}]}>
Stores data in the adapter
</ApiItem>
<ApiItem href="#storageadapterapcu-setforever" visibility="public" name="setForever" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"data","default":null}]}>
Stores data in the adapter forever. The key needs to manually deleted
</ApiItem>
<ApiItem href="#storageadapterapcu-dodecrement" visibility="protected" name="doDecrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Decrements a stored number
</ApiItem>
<ApiItem href="#storageadapterapcu-dodelete" visibility="protected" name="doDelete" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Deletes data from the adapter
</ApiItem>
<ApiItem href="#storageadapterapcu-dodeletemultiple" visibility="protected" name="doDeleteMultiple" returnType="bool" params={[{"type":"array","name":"keys","default":null}]}>
Deletes multiple keys from APCu in a single call
</ApiItem>
<ApiItem href="#storageadapterapcu-dogetdata" visibility="protected" name="doGetData" returnType="mixed" params={[{"type":"string","name":"key","default":null}]}>
</ApiItem>
<ApiItem href="#storageadapterapcu-dohas" visibility="protected" name="doHas" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Checks if an element exists in the cache
</ApiItem>
<ApiItem href="#storageadapterapcu-doincrement" visibility="protected" name="doIncrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Increments a stored number
</ApiItem>
<ApiItem href="#storageadapterapcu-doset" visibility="protected" name="doSet" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"value","default":null},{"type":"mixed","name":"ttl","default":"null"}]}>
Stores data in the adapter. If the TTL is `null` (default) or not defined
</ApiItem>

### Properties

<ApiItem kind="property" visibility="protected" name="prefix" type="string" default="&quot;ph-apcu-&quot;">
</ApiItem>

### Methods

<h4 id="storageadapterapcu-__construct"><code>__construct()</code></h4>

```php
public function __construct(
SerializerFactory $factory,
array $options = []
);
```

Apcu constructor.

<h4 id="storageadapterapcu-clear"><code>clear()</code></h4>

```php
public function clear(): bool;
```

Flushes/clears the cache

<h4 id="storageadapterapcu-getkeys"><code>getKeys()</code></h4>

```php
public function getKeys( string $prefix = "" ): array;
```

Stores data in the adapter

<h4 id="storageadapterapcu-setforever"><code>setForever()</code></h4>

```php
public function setForever(
string $key,
mixed $data
): bool;
```

Stores data in the adapter forever. The key needs to manually deleted
from the adapter.

<h4 id="storageadapterapcu-dodecrement"><code>doDecrement()</code></h4>

```php
protected function doDecrement(
string $key,
int $value = 1
): false|int;
```

Decrements a stored number

<h4 id="storageadapterapcu-dodelete"><code>doDelete()</code></h4>

```php
protected function doDelete( string $key ): bool;
```

Deletes data from the adapter

<h4 id="storageadapterapcu-dodeletemultiple"><code>doDeleteMultiple()</code></h4>

```php
protected function doDeleteMultiple( array $keys ): bool;
```

Deletes multiple keys from APCu in a single call

<h4 id="storageadapterapcu-dogetdata"><code>doGetData()</code></h4>

```php
protected function doGetData( string $key ): mixed;
```

<h4 id="storageadapterapcu-dohas"><code>doHas()</code></h4>

```php
protected function doHas( string $key ): bool;
```

Checks if an element exists in the cache

<h4 id="storageadapterapcu-doincrement"><code>doIncrement()</code></h4>

```php
protected function doIncrement(
string $key,
int $value = 1
): false|int;
```

Increments a stored number

<h4 id="storageadapterapcu-doset"><code>doSet()</code></h4>

```php
protected function doSet(
string $key,
mixed $value,
mixed $ttl = null
): bool;
```

Stores data in the adapter. If the TTL is `null` (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is `0` or a negative number, a `delete()` will be issued, since this
item has expired. If you need to set this key forever, you should use
the `setForever()` method.

## Storage\Adapter\Libmemcached

Class

Libmemcached adapter

Capabilities:
- Counters: native atomic (Memcached::increment()/decrement()).
- getKeys(): Memcached::getAllKeys(), which is server-dependent and may be
  incomplete or unavailable on modern memcached builds.
- Serializers: Phalcon-side plus libmemcached's own options.

- [`Phalcon\Storage\Adapter\AbstractAdapter`](#storageadapterabstractadapter)
- **`Phalcon\Storage\Adapter\Libmemcached`**
- [`Phalcon\Cache\Adapter\Libmemcached`](/5.20/api/phalcon_cache/#cacheadapterlibmemcached)

`DateInterval` · `Exception` · `Memcached` · `Phalcon\Contracts\Storage\StorageTypes` · `Phalcon\Storage\Exception` · `Phalcon\Storage\Exceptions\ConnectionFailed` · `Phalcon\Storage\Exceptions\InvalidConfiguration` · `Phalcon\Storage\SerializerFactory` · `Phalcon\Support\Exception`

### Method Summary

<ApiItem href="#storageadapterlibmemcached-__construct" visibility="public" name="__construct" returnType="" params={[{"type":"SerializerFactory","name":"factory","default":null},{"type":"array","name":"options","default":"[]"}]}>
Libmemcached constructor.
</ApiItem>
<ApiItem href="#storageadapterlibmemcached-clear" visibility="public" name="clear" returnType="bool" params={[]}>
Flushes/clears the cache
</ApiItem>
<ApiItem href="#storageadapterlibmemcached-getadapter" visibility="public" name="getAdapter" returnType="mixed" params={[]}>
Returns the already connected adapter or connects to the Memcached
</ApiItem>
<ApiItem href="#storageadapterlibmemcached-getkeys" visibility="public" name="getKeys" returnType="array" params={[{"type":"string","name":"prefix","default":"\"\""}]}>
Stores data in the adapter
</ApiItem>
<ApiItem href="#storageadapterlibmemcached-setforever" visibility="public" name="setForever" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"data","default":null}]}>
Stores data in the adapter forever. The key needs to be manually deleted
</ApiItem>
<ApiItem href="#storageadapterlibmemcached-dodecrement" visibility="protected" name="doDecrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Decrements a stored number
</ApiItem>
<ApiItem href="#storageadapterlibmemcached-dodelete" visibility="protected" name="doDelete" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Deletes data from the adapter
</ApiItem>
<ApiItem href="#storageadapterlibmemcached-dodeletemultiple" visibility="protected" name="doDeleteMultiple" returnType="bool" params={[{"type":"array","name":"keys","default":null}]}>
Deletes multiple keys from Memcached using a single deleteMulti call
</ApiItem>
<ApiItem href="#storageadapterlibmemcached-dohas" visibility="protected" name="doHas" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Checks if an element exists in the cache
</ApiItem>
<ApiItem href="#storageadapterlibmemcached-doincrement" visibility="protected" name="doIncrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Increments a stored number
</ApiItem>
<ApiItem href="#storageadapterlibmemcached-doset" visibility="protected" name="doSet" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"value","default":null},{"type":"mixed","name":"ttl","default":"null"}]}>
Stores data in the adapter. If the TTL is `null` (default) or not defined
</ApiItem>

### Properties

<ApiItem kind="property" visibility="protected" name="prefix" type="string" default="&quot;ph-memc-&quot;">
</ApiItem>

### Methods

<h4 id="storageadapterlibmemcached-__construct"><code>__construct()</code></h4>

```php
public function __construct(
SerializerFactory $factory,
array $options = []
);
```

Libmemcached constructor.

<h4 id="storageadapterlibmemcached-clear"><code>clear()</code></h4>

```php
public function clear(): bool;
```

Flushes/clears the cache

<h4 id="storageadapterlibmemcached-getadapter"><code>getAdapter()</code></h4>

```php
public function getAdapter(): mixed;
```

Returns the already connected adapter or connects to the Memcached
server(s)

<h4 id="storageadapterlibmemcached-getkeys"><code>getKeys()</code></h4>

```php
public function getKeys( string $prefix = "" ): array;
```

Stores data in the adapter

<h4 id="storageadapterlibmemcached-setforever"><code>setForever()</code></h4>

```php
public function setForever(
string $key,
mixed $data
): bool;
```

Stores data in the adapter forever. The key needs to be manually deleted
from the adapter.

<h4 id="storageadapterlibmemcached-dodecrement"><code>doDecrement()</code></h4>

```php
protected function doDecrement(
string $key,
int $value = 1
): false|int;
```

Decrements a stored number

<h4 id="storageadapterlibmemcached-dodelete"><code>doDelete()</code></h4>

```php
protected function doDelete( string $key ): bool;
```

Deletes data from the adapter

<h4 id="storageadapterlibmemcached-dodeletemultiple"><code>doDeleteMultiple()</code></h4>

```php
protected function doDeleteMultiple( array $keys ): bool;
```

Deletes multiple keys from Memcached using a single deleteMulti call

<h4 id="storageadapterlibmemcached-dohas"><code>doHas()</code></h4>

```php
protected function doHas( string $key ): bool;
```

Checks if an element exists in the cache

<h4 id="storageadapterlibmemcached-doincrement"><code>doIncrement()</code></h4>

```php
protected function doIncrement(
string $key,
int $value = 1
): false|int;
```

Increments a stored number

<h4 id="storageadapterlibmemcached-doset"><code>doSet()</code></h4>

```php
protected function doSet(
string $key,
mixed $value,
mixed $ttl = null
): bool;
```

Stores data in the adapter. If the TTL is `null` (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is `0` or a negative number, a `delete()` will be issued, since this
item has expired. If you need to set this key forever, you should use
the `setForever()` method.

## Storage\Adapter\Memory

Class

Memory adapter

Capabilities:
- Scope: per-request, in-process; nothing is shared across requests or
  processes and the store is discarded when the request ends.
- Counters: read-modify-write on the in-memory array.
- getKeys(): in-memory array scan (cheap).
- Optional maxItems FIFO cap drops the oldest entry before a new key is set.

- [`Phalcon\Storage\Adapter\AbstractAdapter`](#storageadapterabstractadapter)
- **`Phalcon\Storage\Adapter\Memory`**
- [`Phalcon\Cache\Adapter\Memory`](/5.20/api/phalcon_cache/#cacheadaptermemory)

`Exception` · `Phalcon\Contracts\Storage\StorageTypes` · `Phalcon\Storage\SerializerFactory`

### Method Summary

<ApiItem href="#storageadaptermemory-__construct" visibility="public" name="__construct" returnType="" params={[{"type":"SerializerFactory","name":"factory","default":null},{"type":"array","name":"options","default":"[]"}]}>
Memory constructor.
</ApiItem>
<ApiItem href="#storageadaptermemory-clear" visibility="public" name="clear" returnType="bool" params={[]}>
Flushes/clears the cache
</ApiItem>
<ApiItem href="#storageadaptermemory-getkeys" visibility="public" name="getKeys" returnType="array" params={[{"type":"string","name":"prefix","default":"\"\""}]}>
Stores data in the adapter
</ApiItem>
<ApiItem href="#storageadaptermemory-getmaxitems" visibility="public" name="getMaxItems" returnType="int" params={[]}>
Returns the configured store cap (0 = unlimited). See setMaxItems().
</ApiItem>
<ApiItem href="#storageadaptermemory-setforever" visibility="public" name="setForever" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"data","default":null}]}>
Stores data in the adapter forever. The key needs to manually deleted
</ApiItem>
<ApiItem href="#storageadaptermemory-setmaxitems" visibility="public" name="setMaxItems" returnType="static" params={[{"type":"int","name":"maxItems","default":null}]}>
Caps the number of items retained in the in-memory store.
</ApiItem>
<ApiItem href="#storageadaptermemory-dodecrement" visibility="protected" name="doDecrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Decrements a stored number
</ApiItem>
<ApiItem href="#storageadaptermemory-dodelete" visibility="protected" name="doDelete" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Deletes data from the adapter
</ApiItem>
<ApiItem href="#storageadaptermemory-dogetdata" visibility="protected" name="doGetData" returnType="mixed" params={[{"type":"string","name":"key","default":null}]}>
</ApiItem>
<ApiItem href="#storageadaptermemory-dohas" visibility="protected" name="doHas" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Checks if an element exists in the cache
</ApiItem>
<ApiItem href="#storageadaptermemory-doincrement" visibility="protected" name="doIncrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Increments a stored number
</ApiItem>
<ApiItem href="#storageadaptermemory-doset" visibility="protected" name="doSet" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"value","default":null},{"type":"mixed","name":"ttl","default":"null"}]}>
Stores data in the adapter. If the TTL is `null` (default) or not defined
</ApiItem>

### Properties

<ApiItem kind="property" visibility="protected" name="data" type="array&lt;string, mixed&gt;" default="[]">
</ApiItem>
<ApiItem kind="property" visibility="protected" name="maxItems" type="int" default="0">
Maximum number of items retained in the in-memory store.
0 (default) keeps the original unbounded behavior; a positive
value drops the oldest entry FIFO before a new key is stored.
</ApiItem>

### Methods

<h4 id="storageadaptermemory-__construct"><code>__construct()</code></h4>

```php
public function __construct(
SerializerFactory $factory,
array $options = []
);
```

Memory constructor.

<h4 id="storageadaptermemory-clear"><code>clear()</code></h4>

```php
public function clear(): bool;
```

Flushes/clears the cache

<h4 id="storageadaptermemory-getkeys"><code>getKeys()</code></h4>

```php
public function getKeys( string $prefix = "" ): array;
```

Stores data in the adapter

<h4 id="storageadaptermemory-getmaxitems"><code>getMaxItems()</code></h4>

```php
public function getMaxItems(): int;
```

Returns the configured store cap (0 = unlimited). See setMaxItems().

<h4 id="storageadaptermemory-setforever"><code>setForever()</code></h4>

```php
public function setForever(
string $key,
mixed $data
): bool;
```

Stores data in the adapter forever. The key needs to manually deleted
from the adapter.

<h4 id="storageadaptermemory-setmaxitems"><code>setMaxItems()</code></h4>

```php
public function setMaxItems( int $maxItems ): static;
```

Caps the number of items retained in the in-memory store.
0 disables the cap (the default; preserves the original
unbounded behavior). When the cap is exceeded, the oldest
entry is evicted FIFO before a new key is stored.

<h4 id="storageadaptermemory-dodecrement"><code>doDecrement()</code></h4>

```php
protected function doDecrement(
string $key,
int $value = 1
): false|int;
```

Decrements a stored number

<h4 id="storageadaptermemory-dodelete"><code>doDelete()</code></h4>

```php
protected function doDelete( string $key ): bool;
```

Deletes data from the adapter

<h4 id="storageadaptermemory-dogetdata"><code>doGetData()</code></h4>

```php
protected function doGetData( string $key ): mixed;
```

<h4 id="storageadaptermemory-dohas"><code>doHas()</code></h4>

```php
protected function doHas( string $key ): bool;
```

Checks if an element exists in the cache

<h4 id="storageadaptermemory-doincrement"><code>doIncrement()</code></h4>

```php
protected function doIncrement(
string $key,
int $value = 1
): false|int;
```

Increments a stored number

<h4 id="storageadaptermemory-doset"><code>doSet()</code></h4>

```php
protected function doSet(
string $key,
mixed $value,
mixed $ttl = null
): bool;
```

Stores data in the adapter. If the TTL is `null` (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is `0` or a negative number, a `delete()` will be issued, since this
item has expired. If you need to set this key forever, you should use
the `setForever()` method.

## Storage\Adapter\Redis

Class

Redis adapter

Capabilities:
- Counters: native atomic (incrBy()/decrBy()).
- getKeys(): non-blocking SCAN iteration.
- Serializers: Phalcon-side, or backend-native via OPT_SERIALIZER. Native
  serializers change the bytes at rest and are not interchangeable with
  Phalcon-side serializers.

- [`Phalcon\Storage\Adapter\AbstractAdapter`](#storageadapterabstractadapter)
- **`Phalcon\Storage\Adapter\Redis`**
- [`Phalcon\Cache\Adapter\Redis`](/5.20/api/phalcon_cache/#cacheadapterredis)
- [`Phalcon\Storage\Adapter\RedisCluster`](#storageadapterrediscluster)

`DateInterval` · `Exception` · `Phalcon\Contracts\Storage\StorageTypes` · `Phalcon\Storage\Exception` · `Phalcon\Storage\Exceptions\AuthenticationFailed` · `Phalcon\Storage\Exceptions\ConnectionFailed` · `Phalcon\Storage\Exceptions\DatabaseSelectionFailed` · `Phalcon\Storage\SerializerFactory` · `Redis` · `RedisException`

### Method Summary

<ApiItem href="#storageadapterredis-__construct" visibility="public" name="__construct" returnType="" params={[{"type":"SerializerFactory","name":"factory","default":null},{"type":"array","name":"options","default":"[]"}]}>
Redis constructor.
</ApiItem>
<ApiItem href="#storageadapterredis-clear" visibility="public" name="clear" returnType="bool" params={[]}>
Flushes/clears the cache
</ApiItem>
<ApiItem href="#storageadapterredis-getadapter" visibility="public" name="getAdapter" returnType="mixed" params={[]}>
Returns the already connected adapter or connects to the Redis
</ApiItem>
<ApiItem href="#storageadapterredis-getkeys" visibility="public" name="getKeys" returnType="array" params={[{"type":"string","name":"prefix","default":"\"\""}]}>
Returns all the keys stored
</ApiItem>
<ApiItem href="#storageadapterredis-setforever" visibility="public" name="setForever" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"data","default":null}]}>
Stores data in the adapter forever. The key needs to manually deleted
</ApiItem>
<ApiItem href="#storageadapterredis-dodecrement" visibility="protected" name="doDecrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Decrements a stored number
</ApiItem>
<ApiItem href="#storageadapterredis-dodelete" visibility="protected" name="doDelete" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Deletes data from the adapter
</ApiItem>
<ApiItem href="#storageadapterredis-dodeletemultiple" visibility="protected" name="doDeleteMultiple" returnType="bool" params={[{"type":"array","name":"keys","default":null}]}>
Deletes multiple keys from Redis using a single unlink call
</ApiItem>
<ApiItem href="#storageadapterredis-dohas" visibility="protected" name="doHas" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Checks if an element exists in the cache
</ApiItem>
<ApiItem href="#storageadapterredis-doincrement" visibility="protected" name="doIncrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Increments a stored number
</ApiItem>
<ApiItem href="#storageadapterredis-doset" visibility="protected" name="doSet" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"value","default":null},{"type":"mixed","name":"ttl","default":"null"}]}>
Stores data in the adapter. If the TTL is `null` (default) or not defined
</ApiItem>
<ApiItem href="#storageadapterredis-getdefaultoptions" visibility="protected" name="getDefaultOptions" returnType="array" params={[{"type":"array","name":"options","default":null}]}>
The parameter is the raw, user supplied options array; `RedisCluster`
</ApiItem>

### Properties

<ApiItem kind="property" visibility="protected" name="prefix" type="string" default="&quot;ph-reds-&quot;">
</ApiItem>

### Methods

<h4 id="storageadapterredis-__construct"><code>__construct()</code></h4>

```php
public function __construct(
SerializerFactory $factory,
array $options = []
);
```

Redis constructor.

<h4 id="storageadapterredis-clear"><code>clear()</code></h4>

```php
public function clear(): bool;
```

Flushes/clears the cache

<h4 id="storageadapterredis-getadapter"><code>getAdapter()</code></h4>

```php
public function getAdapter(): mixed;
```

Returns the already connected adapter or connects to the Redis
server(s)

The return type is deliberately left wide: RedisCluster extends this
adapter and hands back a `RedisCluster` client, which is not a `Redis`.
Callers inside this class narrow it to `RedisService` locally.

<h4 id="storageadapterredis-getkeys"><code>getKeys()</code></h4>

```php
public function getKeys( string $prefix = "" ): array;
```

Returns all the keys stored

SCAN replaces the blocking KEYS command. SCAN_NOPREFIX keeps the prefix
handling explicit: the physical prefix is matched and returned unchanged,
so getFilteredKeys() sees exactly what KEYS produced.

<h4 id="storageadapterredis-setforever"><code>setForever()</code></h4>

```php
public function setForever(
string $key,
mixed $data
): bool;
```

Stores data in the adapter forever. The key needs to manually deleted
from the adapter.

<h4 id="storageadapterredis-dodecrement"><code>doDecrement()</code></h4>

```php
protected function doDecrement(
string $key,
int $value = 1
): false|int;
```

Decrements a stored number

<h4 id="storageadapterredis-dodelete"><code>doDelete()</code></h4>

```php
protected function doDelete( string $key ): bool;
```

Deletes data from the adapter

<h4 id="storageadapterredis-dodeletemultiple"><code>doDeleteMultiple()</code></h4>

```php
protected function doDeleteMultiple( array $keys ): bool;
```

Deletes multiple keys from Redis using a single unlink call

<h4 id="storageadapterredis-dohas"><code>doHas()</code></h4>

```php
protected function doHas( string $key ): bool;
```

Checks if an element exists in the cache

<h4 id="storageadapterredis-doincrement"><code>doIncrement()</code></h4>

```php
protected function doIncrement(
string $key,
int $value = 1
): false|int;
```

Increments a stored number

<h4 id="storageadapterredis-doset"><code>doSet()</code></h4>

```php
protected function doSet(
string $key,
mixed $value,
mixed $ttl = null
): bool;
```

Stores data in the adapter. If the TTL is `null` (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is `0` or a negative number, a `delete()` will be issued, since this
item has expired. If you need to set this key forever, you should use
the `setForever()` method.

<h4 id="storageadapterredis-getdefaultoptions"><code>getDefaultOptions()</code></h4>

```php
protected function getDefaultOptions( array $options ): array;
```

The parameter is the raw, user supplied options array; `RedisCluster`
overrides this method with its own set of keys, so the two signatures
have to agree on the wider type.

## Storage\Adapter\RedisCluster

Class

RedisCluster adapter

Capabilities (in addition to Redis):
- Counters: native atomic (incrBy()/decrBy()).
- getKeys(): blocking KEYS across all master nodes (per-node SCAN is left to
  the redesign); clear() flushes every master.
- Serializers: Phalcon-side, or backend-native via OPT_SERIALIZER.

- [`Phalcon\Storage\Adapter\AbstractAdapter`](#storageadapterabstractadapter)
- [`Phalcon\Storage\Adapter\Redis`](#storageadapterredis)
- **`Phalcon\Storage\Adapter\RedisCluster`**
- [`Phalcon\Cache\Adapter\RedisCluster`](/5.20/api/phalcon_cache/#cacheadapterrediscluster)

`Phalcon\Contracts\Storage\StorageTypes` · `Phalcon\Storage\Exceptions\ClusterConnectionFailed` · `Phalcon\Storage\SerializerFactory` · `Phalcon\Support\Exception` · `Redis` · `RedisCluster` · `Throwable`

### Method Summary

<ApiItem href="#storageadapterrediscluster-__construct" visibility="public" name="__construct" returnType="" params={[{"type":"SerializerFactory","name":"factory","default":null},{"type":"array","name":"options","default":"[]"}]}>
You can create and connect to a cluster either by passing it one or more
</ApiItem>
<ApiItem href="#storageadapterrediscluster-clear" visibility="public" name="clear" returnType="bool" params={[]}>
Flushes/clears the cache
</ApiItem>
<ApiItem href="#storageadapterrediscluster-getadapter" visibility="public" name="getAdapter" returnType="mixed" params={[]}>
Returns the already connected adapter or connects to the Redis
</ApiItem>
<ApiItem href="#storageadapterrediscluster-getkeys" visibility="public" name="getKeys" returnType="array" params={[{"type":"string","name":"prefix","default":"\"\""}]}>
Returns all the keys stored
</ApiItem>
<ApiItem href="#storageadapterrediscluster-getdefaultoptions" visibility="protected" name="getDefaultOptions" returnType="array" params={[{"type":"array","name":"options","default":null}]}>
</ApiItem>

### Properties

<ApiItem kind="property" visibility="protected" name="prefix" type="string" default="&quot;ph-redc-&quot;">
</ApiItem>

### Methods

<h4 id="storageadapterrediscluster-__construct"><code>__construct()</code></h4>

```php
public function __construct(
SerializerFactory $factory,
array $options = []
);
```

You can create and connect to a cluster either by passing it one or more
'seed' nodes, or by defining these in redis.ini as a 'named' cluster.

If you are connecting with the cluster by offering a name, that is
configured in redis.ini:

```
 # In redis.ini
 redis.clusters.seeds = "mycluster[]=localhost:7000&test[]=localhost:7001"
 redis.clusters.timeout = "mycluster=5"
 redis.clusters.read_timeout = "mycluster=10"
 redis.clusters.auth = "mycluster=password"
```
you can use `$options = ["name" => "mycluster"]`.

If you don't have cluster seeds configured in your redis.ini,
you should pass hosts as an array,
eg. `$options = ["hosts" => ["a-host:7000", "b-host:7001"]]`.

You can provide authentication data offering a string `user=password`
or array `["user" => "name", "password" => "secret"]`.

The `timeout` is the amount of time library will wait when connecting
or writing to the cluster. `readTimeout` is the amount of time library
will wait for a result from the cluster.

The `context` is an array of values used for ssl/tls stream context
options eg `["verify_peer" => 0, "local_cert" => "file:///path/to/cert.pem"]`

<h4 id="storageadapterrediscluster-clear"><code>clear()</code></h4>

```php
public function clear(): bool;
```

Flushes/clears the cache

<h4 id="storageadapterrediscluster-getadapter"><code>getAdapter()</code></h4>

```php
public function getAdapter(): mixed;
```

Returns the already connected adapter or connects to the Redis
server(s)

<h4 id="storageadapterrediscluster-getkeys"><code>getKeys()</code></h4>

```php
public function getKeys( string $prefix = "" ): array;
```

Returns all the keys stored

RedisCluster::scan() iterates one node at a time, so the blocking KEYS
command is retained here (phpredis routes it across the masters). The
per-node SCAN migration is left to the storage redesign.

<h4 id="storageadapterrediscluster-getdefaultoptions"><code>getDefaultOptions()</code></h4>

```php
protected function getDefaultOptions( array $options ): array;
```

## Storage\Adapter\Stream

Class

Stream adapter

Capabilities:
- Counters: read-modify-write (doHas()/doGet()/doSet()); not atomic and racy
  across concurrent processes.
- getKeys(): recursive directory traversal; cost grows with the entry count.
- Serializers: Phalcon-side only.

- [`Phalcon\Storage\Adapter\AbstractAdapter`](#storageadapterabstractadapter)
- **`Phalcon\Storage\Adapter\Stream`**
- [`Phalcon\Cache\Adapter\Stream`](/5.20/api/phalcon_cache/#cacheadapterstream)

`FilesystemIterator` · `Iterator` · `Phalcon\Contracts\Storage\StorageTypes` · `Phalcon\Storage\Exceptions\InvalidConfiguration` · `Phalcon\Storage\SerializerFactory` · `Phalcon\Traits\Php\FileTrait` · `Phalcon\Traits\Support\Helper\Str\DirFromFileTrait` · `Phalcon\Traits\Support\Helper\Str\DirSeparatorTrait` · `RecursiveDirectoryIterator` · `RecursiveIteratorIterator` · `SplFileInfo`

### Method Summary

<ApiItem href="#storageadapterstream-__construct" visibility="public" name="__construct" returnType="" params={[{"type":"SerializerFactory","name":"factory","default":null},{"type":"array","name":"options","default":"[]"}]}>
Stream constructor.
</ApiItem>
<ApiItem href="#storageadapterstream-clear" visibility="public" name="clear" returnType="bool" params={[]}>
Flushes/clears the cache
</ApiItem>
<ApiItem href="#storageadapterstream-getkeys" visibility="public" name="getKeys" returnType="array" params={[{"type":"string","name":"prefix","default":"\"\""}]}>
Stores data in the adapter
</ApiItem>
<ApiItem href="#storageadapterstream-setforever" visibility="public" name="setForever" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"data","default":null}]}>
Stores data in the adapter forever. The key needs to manually deleted
</ApiItem>
<ApiItem href="#storageadapterstream-dodecrement" visibility="protected" name="doDecrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Decrements a stored number
</ApiItem>
<ApiItem href="#storageadapterstream-dodelete" visibility="protected" name="doDelete" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Deletes data from the adapter
</ApiItem>
<ApiItem href="#storageadapterstream-doget" visibility="protected" name="doGet" returnType="mixed" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"defaultValue","default":"null"}]}>
Reads data from the adapter
</ApiItem>
<ApiItem href="#storageadapterstream-dohas" visibility="protected" name="doHas" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Checks if an element exists in the cache and is not expired
</ApiItem>
<ApiItem href="#storageadapterstream-doincrement" visibility="protected" name="doIncrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Increments a stored number
</ApiItem>
<ApiItem href="#storageadapterstream-doset" visibility="protected" name="doSet" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"value","default":null},{"type":"mixed","name":"ttl","default":"null"}]}>
Stores data in the adapter. If the TTL is `null` (default) or not defined
</ApiItem>

### Properties

<ApiItem kind="property" visibility="protected" name="prefix" type="string" default="&quot;ph-strm&quot;">
</ApiItem>
<ApiItem kind="property" visibility="protected" name="storageDir" type="string" default="&quot;&quot;">
</ApiItem>

### Methods

<h4 id="storageadapterstream-__construct"><code>__construct()</code></h4>

```php
public function __construct(
SerializerFactory $factory,
array $options = []
);
```

Stream constructor.

<h4 id="storageadapterstream-clear"><code>clear()</code></h4>

```php
public function clear(): bool;
```

Flushes/clears the cache

<h4 id="storageadapterstream-getkeys"><code>getKeys()</code></h4>

```php
public function getKeys( string $prefix = "" ): array;
```

Stores data in the adapter

<h4 id="storageadapterstream-setforever"><code>setForever()</code></h4>

```php
public function setForever(
string $key,
mixed $data
): bool;
```

Stores data in the adapter forever. The key needs to manually deleted
from the adapter.

<h4 id="storageadapterstream-dodecrement"><code>doDecrement()</code></h4>

```php
protected function doDecrement(
string $key,
int $value = 1
): false|int;
```

Decrements a stored number

<h4 id="storageadapterstream-dodelete"><code>doDelete()</code></h4>

```php
protected function doDelete( string $key ): bool;
```

Deletes data from the adapter

<h4 id="storageadapterstream-doget"><code>doGet()</code></h4>

```php
protected function doGet(
string $key,
mixed $defaultValue = null
): mixed;
```

Reads data from the adapter

<h4 id="storageadapterstream-dohas"><code>doHas()</code></h4>

```php
protected function doHas( string $key ): bool;
```

Checks if an element exists in the cache and is not expired

<h4 id="storageadapterstream-doincrement"><code>doIncrement()</code></h4>

```php
protected function doIncrement(
string $key,
int $value = 1
): false|int;
```

Increments a stored number

<h4 id="storageadapterstream-doset"><code>doSet()</code></h4>

```php
protected function doSet(
string $key,
mixed $value,
mixed $ttl = null
): bool;
```

Stores data in the adapter. If the TTL is `null` (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is `0` or a negative number, a `delete()` will be issued, since this
item has expired. If you need to set this key forever, you should use
the `setForever()` method.

## Storage\Adapter\Weak

Class

Weak Adapter

Capabilities:
- Stores objects only, as WeakReferences; entries vanish when the referenced
  object is garbage-collected.
- TTL is ignored; no serializer is used (none/no-op).
- Counters unsupported: increment()/decrement() return false.
- setForever() is equivalent to set(); getKeys() reads the in-memory list.

- [`Phalcon\Storage\Adapter\AbstractAdapter`](#storageadapterabstractadapter)
- **`Phalcon\Storage\Adapter\Weak`**
- [`Phalcon\Cache\Adapter\Weak`](/5.20/api/phalcon_cache/#cacheadapterweak)

`Exception` · `Phalcon\Contracts\Storage\StorageTypes` · `Phalcon\Storage\SerializerFactory` · `WeakReference`

### Method Summary

<ApiItem href="#storageadapterweak-__construct" visibility="public" name="__construct" returnType="" params={[{"type":"SerializerFactory","name":"factory","default":null},{"type":"array","name":"options","default":"[]"}]}>
Constructor, there are no options
</ApiItem>
<ApiItem href="#storageadapterweak-clear" visibility="public" name="clear" returnType="bool" params={[]}>
Flushes/clears the cache
</ApiItem>
<ApiItem href="#storageadapterweak-getkeys" visibility="public" name="getKeys" returnType="array" params={[{"type":"string","name":"prefix","default":"\"\""}]}>
Stores data in the adapter
</ApiItem>
<ApiItem href="#storageadapterweak-setdefaultserializer" visibility="public" name="setDefaultSerializer" returnType="void" params={[{"type":"string","name":"serializer","default":null}]}>
Will never set a serializer, WeakReference cannot be serialized
</ApiItem>
<ApiItem href="#storageadapterweak-setforever" visibility="public" name="setForever" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"data","default":null}]}>
For compatiblity only, there is no Forever with WeakReference.
</ApiItem>
<ApiItem href="#storageadapterweak-dodecrement" visibility="protected" name="doDecrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Decrements a stored number - not supported for WeakReference
</ApiItem>
<ApiItem href="#storageadapterweak-dodelete" visibility="protected" name="doDelete" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Deletes data from the adapter
</ApiItem>
<ApiItem href="#storageadapterweak-doget" visibility="protected" name="doGet" returnType="mixed" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"defaultValue","default":"null"}]}>
Reads data from the adapter
</ApiItem>
<ApiItem href="#storageadapterweak-dohas" visibility="protected" name="doHas" returnType="bool" params={[{"type":"string","name":"key","default":null}]}>
Checks if an element exists in the cache
</ApiItem>
<ApiItem href="#storageadapterweak-doincrement" visibility="protected" name="doIncrement" returnType="false|int" params={[{"type":"string","name":"key","default":null},{"type":"int","name":"value","default":"1"}]}>
Increments a stored number - not supported for WeakReference
</ApiItem>
<ApiItem href="#storageadapterweak-doset" visibility="protected" name="doSet" returnType="bool" params={[{"type":"string","name":"key","default":null},{"type":"mixed","name":"value","default":null},{"type":"mixed","name":"ttl","default":"null"}]}>
Stores data in the adapter. If the TTL is `null` (default) or not defined
</ApiItem>

### Properties

<ApiItem kind="property" visibility="protected" name="fetching" type="string|null" default="null">
</ApiItem>
<ApiItem kind="property" visibility="protected" name="options" type="array&lt;string, mixed&gt;" default="[]">
</ApiItem>
<ApiItem kind="property" visibility="protected" name="weakList" type="array&lt;string, WeakReference&lt;object&gt;&gt;" default="[]">
</ApiItem>

### Methods

<h4 id="storageadapterweak-__construct"><code>__construct()</code></h4>

```php
public function __construct(
SerializerFactory $factory,
array $options = []
);
```

Constructor, there are no options

<h4 id="storageadapterweak-clear"><code>clear()</code></h4>

```php
public function clear(): bool;
```

Flushes/clears the cache

<h4 id="storageadapterweak-getkeys"><code>getKeys()</code></h4>

```php
public function getKeys( string $prefix = "" ): array;
```

Stores data in the adapter

<h4 id="storageadapterweak-setdefaultserializer"><code>setDefaultSerializer()</code></h4>

```php
public function setDefaultSerializer( string $serializer ): void;
```

Will never set a serializer, WeakReference cannot be serialized

<h4 id="storageadapterweak-setforever"><code>setForever()</code></h4>

```php
public function setForever(
string $key,
mixed $data
): bool;
```

For compatiblity only, there is no Forever with WeakReference.

<h4 id="storageadapterweak-dodecrement"><code>doDecrement()</code></h4>

```php
protected function doDecrement(
string $key,
int $value = 1
): false|int;
```

Decrements a stored number - not supported for WeakReference

<h4 id="storageadapterweak-dodelete"><code>doDelete()</code></h4>

```php
protected function doDelete( string $key ): bool;
```

Deletes data from the adapter

<h4 id="storageadapterweak-doget"><code>doGet()</code></h4>

```php
protected function doGet(
string $key,
mixed $defaultValue = null
): mixed;
```

Reads data from the adapter

<h4 id="storageadapterweak-dohas"><code>doHas()</code></h4>

```php
protected function doHas( string $key ): bool;
```

Checks if an element exists in the cache

<h4 id="storageadapterweak-doincrement"><code>doIncrement()</code></h4>

```php
protected function doIncrement(
string $key,
int $value = 1
): false|int;
```

Increments a stored number - not supported for WeakReference

<h4 id="storageadapterweak-doset"><code>doSet()</code></h4>

```php
protected function doSet(
string $key,
mixed $value,
mixed $ttl = null
): bool;
```

Stores data in the adapter. If the TTL is `null` (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is `0` or a negative number, a `delete()` will be issued, since this
item has expired. If you need to set this key forever, you should use
the `setForever()` method.

## Storage\Exception

Class

Phalcon\Storage\Exception

Exceptions thrown in Phalcon\Storage will use this class

- `\Exception`
- **`Phalcon\Storage\Exception`**
- [`Phalcon\Storage\Exceptions\AuthenticationFailed`](#storageexceptionsauthenticationfailed)
- [`Phalcon\Storage\Exceptions\ClusterConnectionFailed`](#storageexceptionsclusterconnectionfailed)
- [`Phalcon\Storage\Exceptions\ConnectionFailed`](#storageexceptionsconnectionfailed)
- [`Phalcon\Storage\Exceptions\DatabaseSelectionFailed`](#storageexceptionsdatabaseselectionfailed)
- [`Phalcon\Storage\Exceptions\InvalidConfiguration`](#storageexceptionsinvalidconfiguration)
- [`Phalcon\Storage\Exceptions\StorageError`](#storageexceptionsstorageerror)

## Storage\Exceptions\AuthenticationFailed

Class

- `\Exception`
- [`Phalcon\Storage\Exception`](#storageexception)
- **`Phalcon\Storage\Exceptions\AuthenticationFailed`**

`Phalcon\Storage\Exception`

### Method Summary

<ApiItem href="#storageexceptionsauthenticationfailed-__construct" visibility="public" name="__construct" returnType="" params={[]}>
</ApiItem>

### Methods

<h4 id="storageexceptionsauthenticationfailed-__construct"><code>__construct()</code></h4>

```php
public function __construct();
```

## Storage\Exceptions\ClusterConnectionFailed

Class

- `\Exception`
- [`Phalcon\Storage\Exception`](#storageexception)
- **`Phalcon\Storage\Exceptions\ClusterConnectionFailed`**

`Phalcon\Storage\Exception`

## Storage\Exceptions\ConnectionFailed

Class

- `\Exception`
- [`Phalcon\Storage\Exception`](#storageexception)
- **`Phalcon\Storage\Exceptions\ConnectionFailed`**

`Phalcon\Storage\Exception`

## Storage\Exceptions\DatabaseSelectionFailed

Class

- `\Exception`
- [`Phalcon\Storage\Exception`](#storageexception)
- **`Phalcon\Storage\Exceptions\DatabaseSelectionFailed`**

`Phalcon\Storage\Exception`

### Method Summary

<ApiItem href="#storageexceptionsdatabaseselectionfailed-__construct" visibility="public" name="__construct" returnType="" params={[]}>
</ApiItem>

### Methods

<h4 id="storageexceptionsdatabaseselectionfailed-__construct"><code>__construct()</code></h4>

```php
public function __construct();
```

## Storage\Exceptions\InvalidConfiguration

Class

- `\Exception`
- [`Phalcon\Storage\Exception`](#storageexception)
- **`Phalcon\Storage\Exceptions\InvalidConfiguration`**

`Phalcon\Storage\Exception`

## Storage\Exceptions\StorageError

Class

- `\Exception`
- [`Phalcon\Storage\Exception`](#storageexception)
- **`Phalcon\Storage\Exceptions\StorageError`**

`Phalcon\Storage\Exception`

## Storage\SerializerFactory

Class

- [`Phalcon\Factory\AbstractConfigFactory`](/5.20/api/phalcon_factory/#factoryabstractconfigfactory)
- [`Phalcon\Factory\AbstractFactory`](/5.20/api/phalcon_factory/#factoryabstractfactory)
- **`Phalcon\Storage\SerializerFactory`**

`Exception` · `Phalcon\Contracts\Storage\StorageTypes` · `Phalcon\Factory\AbstractFactory` · `Phalcon\Storage\Serializer\Base64` · `Phalcon\Storage\Serializer\Igbinary` · `Phalcon\Storage\Serializer\Json` · `Phalcon\Storage\Serializer\MemcachedIgbinary` · `Phalcon\Storage\Serializer\MemcachedJson` · `Phalcon\Storage\Serializer\MemcachedPhp` · `Phalcon\Storage\Serializer\Msgpack` · `Phalcon\Storage\Serializer\None` · `Phalcon\Storage\Serializer\Php` · `Phalcon\Storage\Serializer\RedisIgbinary` · `Phalcon\Storage\Serializer\RedisJson` · `Phalcon\Storage\Serializer\RedisMsgpack` · `Phalcon\Storage\Serializer\RedisNone` · `Phalcon\Storage\Serializer\RedisPhp` · `Phalcon\Storage\Serializer\SerializerInterface` · `Throwable`

### Method Summary

<ApiItem href="#storageserializerfactory-__construct" visibility="public" name="__construct" returnType="" params={[{"type":"array","name":"services","default":"[]"}]}>
SerializerFactory constructor.
</ApiItem>
<ApiItem href="#storageserializerfactory-newinstance" visibility="public" name="newInstance" returnType="SerializerInterface" params={[{"type":"string","name":"name","default":null}]}>
</ApiItem>
<ApiItem href="#storageserializerfactory-getexceptionclass" visibility="protected" name="getExceptionClass" returnType="string" params={[]}>
</ApiItem>
<ApiItem href="#storageserializerfactory-getservices" visibility="protected" name="getServices" returnType="array" params={[]}>
Returns the available adapters
</ApiItem>

### Methods

<h4 id="storageserializerfactory-__construct"><code>__construct()</code></h4>

```php
public function __construct( array $services = [] );
```

SerializerFactory constructor.

<h4 id="storageserializerfactory-newinstance"><code>newInstance()</code></h4>

```php
public function newInstance( string $name ): SerializerInterface;
```

<h4 id="storageserializerfactory-getexceptionclass"><code>getExceptionClass()</code></h4>

```php
protected function getExceptionClass(): string;
```

<h4 id="storageserializerfactory-getservices"><code>getServices()</code></h4>

```php
protected function getServices(): array;
```

Returns the available adapters

## Storage\Serializer\AbstractSerializer

Abstract

@property mixed $data
@property bool  $isSuccess

- **`Phalcon\Storage\Serializer\AbstractSerializer`** - implements [`Phalcon\Storage\Serializer\SerializerInterface`](#storageserializerserializerinterface)
- [`Phalcon\Storage\Serializer\Base64`](#storageserializerbase64)
- [`Phalcon\Storage\Serializer\Igbinary`](#storageserializerigbinary)
- [`Phalcon\Storage\Serializer\Json`](#storageserializerjson)
- [`Phalcon\Storage\Serializer\None`](#storageserializernone)
- [`Phalcon\Storage\Serializer\Php`](#storageserializerphp)

`Phalcon\Contracts\Storage\StorageTypes`

### Method Summary

<ApiItem href="#storageserializerabstractserializer-__construct" visibility="public" name="__construct" returnType="" params={[{"type":"mixed","name":"data","default":"null"}]}>
AbstractSerializer constructor.
</ApiItem>
<ApiItem href="#storageserializerabstractserializer-__serialize" visibility="public" name="__serialize" returnType="array" params={[]}>
Serialize data
</ApiItem>
<ApiItem href="#storageserializerabstractserializer-__unserialize" visibility="public" name="__unserialize" returnType="void" params={[{"type":"array","name":"data","default":null}]}>
Unserialize data
</ApiItem>
<ApiItem href="#storageserializerabstractserializer-getdata" visibility="public" name="getData" returnType="mixed" params={[]}>
</ApiItem>
<ApiItem href="#storageserializerabstractserializer-issuccess" visibility="public" name="isSuccess" returnType="bool" params={[]}>
Returns `true` if the serialize/unserialize operation was successful;
</ApiItem>
<ApiItem href="#storageserializerabstractserializer-setdata" visibility="public" name="setData" returnType="void" params={[{"type":"mixed","name":"data","default":null}]}>
</ApiItem>
<ApiItem href="#storageserializerabstractserializer-isserializable" visibility="protected" name="isSerializable" returnType="bool" params={[{"type":"mixed","name":"data","default":null}]}>
If this returns true, then the data is returned as is
</ApiItem>

### Properties

<ApiItem kind="property" visibility="protected" name="data" type="mixed" default="null">
</ApiItem>
<ApiItem kind="property" visibility="protected" name="isSuccess" type="bool" default="true">
</ApiItem>

### Methods

<h4 id="storageserializerabstractserializer-__construct"><code>__construct()</code></h4>

```php
public function __construct( mixed $data = null );
```

AbstractSerializer constructor.

<h4 id="storageserializerabstractserializer-__serialize"><code>__serialize()</code></h4>

```php
public function __serialize(): array;
```

Serialize data

<h4 id="storageserializerabstractserializer-__unserialize"><code>__unserialize()</code></h4>

```php
public function __unserialize( array $data ): void;
```

Unserialize data

<h4 id="storageserializerabstractserializer-getdata"><code>getData()</code></h4>

```php
public function getData(): mixed;
```

<h4 id="storageserializerabstractserializer-issuccess"><code>isSuccess()</code></h4>

```php
public function isSuccess(): bool;
```

Returns `true` if the serialize/unserialize operation was successful;
`false` otherwise

<h4 id="storageserializerabstractserializer-setdata"><code>setData()</code></h4>

```php
public function setData( mixed $data ): void;
```

<h4 id="storageserializerabstractserializer-isserializable"><code>isSerializable()</code></h4>

```php
protected function isSerializable( mixed $data ): bool;
```

If this returns true, then the data is returned as is

## Storage\Serializer\Base64

Class

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- **`Phalcon\Storage\Serializer\Base64`**

`Phalcon\Storage\Serializer\Exceptions\InvalidSerializationInput` · `Phalcon\Storage\Serializer\Exceptions\InvalidUnserializationInput` · `Phalcon\Traits\Php\Base64Trait`

### Method Summary

<ApiItem href="#storageserializerbase64-serialize" visibility="public" name="serialize" returnType="string" params={[]}>
Serializes data
</ApiItem>
<ApiItem href="#storageserializerbase64-unserialize" visibility="public" name="unserialize" returnType="void" params={[{"type":"mixed","name":"data","default":null}]}>
Unserializes data
</ApiItem>

### Methods

<h4 id="storageserializerbase64-serialize"><code>serialize()</code></h4>

```php
public function serialize(): string;
```

Serializes data

<h4 id="storageserializerbase64-unserialize"><code>unserialize()</code></h4>

```php
public function unserialize( mixed $data ): void;
```

Unserializes data

## Storage\Serializer\Exceptions\InvalidSerializationInput

Class

- `\InvalidArgumentException`
- **`Phalcon\Storage\Serializer\Exceptions\InvalidSerializationInput`**

`InvalidArgumentException`

### Method Summary

<ApiItem href="#storageserializerexceptionsinvalidserializationinput-__construct" visibility="public" name="__construct" returnType="" params={[]}>
</ApiItem>

### Methods

<h4 id="storageserializerexceptionsinvalidserializationinput-__construct"><code>__construct()</code></h4>

```php
public function __construct();
```

## Storage\Serializer\Exceptions\InvalidUnserializationInput

Class

- `\InvalidArgumentException`
- **`Phalcon\Storage\Serializer\Exceptions\InvalidUnserializationInput`**

`InvalidArgumentException`

### Method Summary

<ApiItem href="#storageserializerexceptionsinvalidunserializationinput-__construct" visibility="public" name="__construct" returnType="" params={[]}>
</ApiItem>

### Methods

<h4 id="storageserializerexceptionsinvalidunserializationinput-__construct"><code>__construct()</code></h4>

```php
public function __construct();
```

## Storage\Serializer\Igbinary

Class

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- **`Phalcon\Storage\Serializer\Igbinary`**
- [`Phalcon\Storage\Serializer\Msgpack`](#storageserializermsgpack)

`Phalcon\Traits\Php\IgbinaryTrait`

### Method Summary

<ApiItem href="#storageserializerigbinary-serialize" visibility="public" name="serialize" returnType="mixed" params={[]}>
Serializes data
</ApiItem>
<ApiItem href="#storageserializerigbinary-unserialize" visibility="public" name="unserialize" returnType="void" params={[{"type":"mixed","name":"data","default":null}]}>
Unserializes data
</ApiItem>
<ApiItem href="#storageserializerigbinary-doserialize" visibility="protected" name="doSerialize" returnType="string|null" params={[{"type":"mixed","name":"value","default":null}]}>
Serialize
</ApiItem>
<ApiItem href="#storageserializerigbinary-dounserialize" visibility="protected" name="doUnserialize" returnType="" params={[{"type":"mixed","name":"value","default":null}]}>
Unserialize
</ApiItem>

### Methods

<h4 id="storageserializerigbinary-serialize"><code>serialize()</code></h4>

```php
public function serialize(): mixed;
```

Serializes data

<h4 id="storageserializerigbinary-unserialize"><code>unserialize()</code></h4>

```php
public function unserialize( mixed $data ): void;
```

Unserializes data

<h4 id="storageserializerigbinary-doserialize"><code>doSerialize()</code></h4>

```php
protected function doSerialize( mixed $value ): string|null;
```

Serialize

<h4 id="storageserializerigbinary-dounserialize"><code>doUnserialize()</code></h4>

```php
protected function doUnserialize( mixed $value );
```

Unserialize

## Storage\Serializer\Json

Class

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- **`Phalcon\Storage\Serializer\Json`**

`Phalcon\Support\Helper\Json\Decode` · `Phalcon\Support\Helper\Json\Encode`

### Method Summary

<ApiItem href="#storageserializerjson-__construct" visibility="public" name="__construct" returnType="" params={[{"type":"mixed","name":"data","default":"null"}]}>
AbstractSerializer constructor.
</ApiItem>
<ApiItem href="#storageserializerjson-serialize" visibility="public" name="serialize" returnType="mixed" params={[]}>
Serializes data
</ApiItem>
<ApiItem href="#storageserializerjson-unserialize" visibility="public" name="unserialize" returnType="void" params={[{"type":"mixed","name":"data","default":null}]}>
Unserializes data
</ApiItem>

### Methods

<h4 id="storageserializerjson-__construct"><code>__construct()</code></h4>

```php
public function __construct( mixed $data = null );
```

AbstractSerializer constructor.

<h4 id="storageserializerjson-serialize"><code>serialize()</code></h4>

```php
public function serialize(): mixed;
```

Serializes data

<h4 id="storageserializerjson-unserialize"><code>unserialize()</code></h4>

```php
public function unserialize( mixed $data ): void;
```

Unserializes data

## Storage\Serializer\MemcachedIgbinary

Class

Serializer using the built-in Memcached 'igbinary' serializer

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- [`Phalcon\Storage\Serializer\None`](#storageserializernone)
- **`Phalcon\Storage\Serializer\MemcachedIgbinary`**

## Storage\Serializer\MemcachedJson

Class

Serializer using the built-in Memcached 'json' serializer

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- [`Phalcon\Storage\Serializer\None`](#storageserializernone)
- **`Phalcon\Storage\Serializer\MemcachedJson`**

## Storage\Serializer\MemcachedPhp

Class

Serializer using the built-in Memcached 'php' serializer

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- [`Phalcon\Storage\Serializer\None`](#storageserializernone)
- **`Phalcon\Storage\Serializer\MemcachedPhp`**

## Storage\Serializer\Msgpack

Class

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- [`Phalcon\Storage\Serializer\Igbinary`](#storageserializerigbinary)
- **`Phalcon\Storage\Serializer\Msgpack`**

`Phalcon\Traits\Php\MsgpackTrait`

### Method Summary

<ApiItem href="#storageserializermsgpack-doserialize" visibility="protected" name="doSerialize" returnType="string" params={[{"type":"mixed","name":"value","default":null}]}>
Serializes data
</ApiItem>
<ApiItem href="#storageserializermsgpack-dounserialize" visibility="protected" name="doUnserialize" returnType="" params={[{"type":"mixed","name":"value","default":null}]}>
</ApiItem>

### Methods

<h4 id="storageserializermsgpack-doserialize"><code>doSerialize()</code></h4>

```php
protected function doSerialize( mixed $value ): string;
```

Serializes data

<h4 id="storageserializermsgpack-dounserialize"><code>doUnserialize()</code></h4>

```php
protected function doUnserialize( mixed $value );
```

## Storage\Serializer\None

Class

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- **`Phalcon\Storage\Serializer\None`**
- [`Phalcon\Storage\Serializer\MemcachedIgbinary`](#storageserializermemcachedigbinary)
- [`Phalcon\Storage\Serializer\MemcachedJson`](#storageserializermemcachedjson)
- [`Phalcon\Storage\Serializer\MemcachedPhp`](#storageserializermemcachedphp)
- [`Phalcon\Storage\Serializer\RedisIgbinary`](#storageserializerredisigbinary)
- [`Phalcon\Storage\Serializer\RedisJson`](#storageserializerredisjson)
- [`Phalcon\Storage\Serializer\RedisMsgpack`](#storageserializerredismsgpack)
- [`Phalcon\Storage\Serializer\RedisNone`](#storageserializerredisnone)
- [`Phalcon\Storage\Serializer\RedisPhp`](#storageserializerredisphp)

### Method Summary

<ApiItem href="#storageserializernone-serialize" visibility="public" name="serialize" returnType="mixed" params={[]}>
Serializes data
</ApiItem>
<ApiItem href="#storageserializernone-unserialize" visibility="public" name="unserialize" returnType="void" params={[{"type":"mixed","name":"data","default":null}]}>
Unserializes data
</ApiItem>

### Methods

<h4 id="storageserializernone-serialize"><code>serialize()</code></h4>

```php
public function serialize(): mixed;
```

Serializes data

<h4 id="storageserializernone-unserialize"><code>unserialize()</code></h4>

```php
public function unserialize( mixed $data ): void;
```

Unserializes data

## Storage\Serializer\Php

Class

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- **`Phalcon\Storage\Serializer\Php`**

`Phalcon\Storage\Serializer\Exceptions\InvalidUnserializationInput` · `Phalcon\Traits\Php\SerializeTrait`

### Method Summary

<ApiItem href="#storageserializerphp-getallowedclasses" visibility="public" name="getAllowedClasses" returnType="mixed" params={[]}>
</ApiItem>
<ApiItem href="#storageserializerphp-serialize" visibility="public" name="serialize" returnType="mixed" params={[]}>
Serializes data
</ApiItem>
<ApiItem href="#storageserializerphp-setallowedclasses" visibility="public" name="setAllowedClasses" returnType="static" params={[{"type":"mixed","name":"allowedClasses","default":null}]}>
Restricts the classes that unserialize() may instantiate (see the
</ApiItem>
<ApiItem href="#storageserializerphp-unserialize" visibility="public" name="unserialize" returnType="void" params={[{"type":"mixed","name":"data","default":null}]}>
Unserializes data
</ApiItem>

### Properties

<ApiItem kind="property" visibility="protected" name="allowedClasses" type="mixed" default="true">
Classes that unserialize() may instantiate: true (any class, the PHP
default), false (none) or a list of class names. Stored bytes that
try to build another class are rejected on read.
</ApiItem>

### Methods

<h4 id="storageserializerphp-getallowedclasses"><code>getAllowedClasses()</code></h4>

```php
public function getAllowedClasses(): mixed;
```

<h4 id="storageserializerphp-serialize"><code>serialize()</code></h4>

```php
public function serialize(): mixed;
```

Serializes data

<h4 id="storageserializerphp-setallowedclasses"><code>setAllowedClasses()</code></h4>

```php
public function setAllowedClasses( mixed $allowedClasses ): static;
```

Restricts the classes that unserialize() may instantiate (see the
"allowed_classes" option of unserialize()).

<h4 id="storageserializerphp-unserialize"><code>unserialize()</code></h4>

```php
public function unserialize( mixed $data ): void;
```

Unserializes data

## Storage\Serializer\RedisIgbinary

Class

Serializer using the built-in Redis 'igbinary' serializer

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- [`Phalcon\Storage\Serializer\None`](#storageserializernone)
- **`Phalcon\Storage\Serializer\RedisIgbinary`**

## Storage\Serializer\RedisJson

Class

Serializer using the built-in Redis 'json' serializer

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- [`Phalcon\Storage\Serializer\None`](#storageserializernone)
- **`Phalcon\Storage\Serializer\RedisJson`**

## Storage\Serializer\RedisMsgpack

Class

Serializer using the built-in Redis 'msgpack' serializer

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- [`Phalcon\Storage\Serializer\None`](#storageserializernone)
- **`Phalcon\Storage\Serializer\RedisMsgpack`**

## Storage\Serializer\RedisNone

Class

Serializer using the built-in Redis 'none' serializer

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- [`Phalcon\Storage\Serializer\None`](#storageserializernone)
- **`Phalcon\Storage\Serializer\RedisNone`**

## Storage\Serializer\RedisPhp

Class

Serializer using the built-in Redis 'php' serializer

- [`Phalcon\Storage\Serializer\AbstractSerializer`](#storageserializerabstractserializer)
- [`Phalcon\Storage\Serializer\None`](#storageserializernone)
- **`Phalcon\Storage\Serializer\RedisPhp`**

## Storage\Serializer\SerializerInterface

Interface

- **`Phalcon\Storage\Serializer\SerializerInterface`**

### Method Summary

<ApiItem href="#storageserializerserializerinterface-getdata" visibility="public" name="getData" returnType="mixed" params={[]}>
</ApiItem>
<ApiItem href="#storageserializerserializerinterface-serialize" visibility="public" name="serialize" returnType="mixed" params={[]}>
Serializes data
</ApiItem>
<ApiItem href="#storageserializerserializerinterface-setdata" visibility="public" name="setData" returnType="void" params={[{"type":"mixed","name":"data","default":null}]}>
</ApiItem>
<ApiItem href="#storageserializerserializerinterface-unserialize" visibility="public" name="unserialize" returnType="void" params={[{"type":"mixed","name":"data","default":null}]}>
Unserializes data
</ApiItem>

### Methods

<h4 id="storageserializerserializerinterface-getdata"><code>getData()</code></h4>

```php
public function getData(): mixed;
```

<h4 id="storageserializerserializerinterface-serialize"><code>serialize()</code></h4>

```php
public function serialize(): mixed;
```

Serializes data

<h4 id="storageserializerserializerinterface-setdata"><code>setData()</code></h4>

```php
public function setData( mixed $data ): void;
```

<h4 id="storageserializerserializerinterface-unserialize"><code>unserialize()</code></h4>

```php
public function unserialize( mixed $data ): void;
```

Unserializes data

Source: https://docs.phalcon.io/5.20/api/phalcon_storage/index.mdx
