Moodle PHP Documentation 4.4
Moodle 4.4.8+ (Build: 20250530) (000b0c27711)
Redis Class Reference

Caches data to redis. More...

Inheritance diagram for Redis:
Base

Public Member Functions

 __construct ($location, $name, $options=null)
 Create a new cache object.
 
 load ()
 Retrieve the data saved to the cache.
 
 mtime ()
 Retrieve the last modified time for the cache.
 
 save ($data)
 Save data to the cache.
 
 setRedisClient (NativeRedis $cache)
 
 touch ()
 Set the last modified time to the current time.
 
 unlink ()
 Remove the cache.
 

Public Attributes

string const TYPE_FEED = 'spc'
 Feed cache type.
 
string const TYPE_IMAGE = 'spi'
 Image cache type.
 

Protected Attributes

NativeRedis $cache
 Redis instance.
 
string $name
 Cache name.
 
array $options
 Options.
 

Detailed Description

Caches data to redis.

Registered for URLs with the "redis" protocol

For example, redis://localhost:6379/?timeout=3600&prefix=sp_&dbIndex=0 will connect to redis on localhost on port 6379. All tables will be prefixed with simple_primary- and data will expire after 3600 seconds

@subpackage Caching @uses Redis

Deprecated
since SimplePie 1.8.0, use implementation of "Psr::SimpleCache::CacheInterface" instead

Constructor & Destructor Documentation

◆ __construct()

Redis::__construct ( $location,
$name,
$options = null )

Create a new cache object.

Parameters
string$locationLocation string (from SimplePie::$cache_location)
string$nameUnique ID for the cache
Base::TYPE_FEED | Base::TYPE_IMAGE$typeEither TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data

Implements Base.

Member Function Documentation

◆ load()

Redis::load ( )

Retrieve the data saved to the cache.

Return values
arrayData for SimplePie::$data

Implements Base.

◆ mtime()

Redis::mtime ( )

Retrieve the last modified time for the cache.

Return values
intTimestamp

Implements Base.

◆ save()

Redis::save ( $data)

Save data to the cache.

Parameters
array | SimplePie::SimplePie$dataData to store in the cache. If passed a SimplePie object, only cache the $data property
Return values
boolSuccessfulness

Implements Base.

◆ setRedisClient()

Redis::setRedisClient ( NativeRedis $cache)
Parameters
NativeRedis$cache

◆ touch()

Redis::touch ( )

Set the last modified time to the current time.

Return values
boolSuccess status

Implements Base.

◆ unlink()

Redis::unlink ( )

Remove the cache.

Return values
boolSuccess status

Implements Base.


The documentation for this class was generated from the following file: