Granada  1.54.0
Structured layer on top of C++ REST SDK for building server applications in C++. Granada implements sessions, server side plug-in framework, C++ OAuth 2.0 server, data storage access, server script running, server browsing.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
granada::cache::RedisIterator Class Reference

#include <redis_cache_driver.h>

Inheritance diagram for granada::cache::RedisIterator:
granada::cache::CacheHandlerIterator

Public Types

enum  Type { KEYS = 0, SCAN = 1 }
 

Public Member Functions

 RedisIterator ()
 
 RedisIterator (const std::string &expression)
 
 RedisIterator (RedisIterator::Type type, const std::string &expression)
 
virtual ~RedisIterator ()
 
virtual void set (const std::string &expression) override
 
void set (RedisIterator::Type type, const std::string &expression)
 
virtual const bool has_next ()
 
virtual const std::string next ()
 
- Public Member Functions inherited from granada::cache::CacheHandlerIterator
 CacheHandlerIterator ()
 
 CacheHandlerIterator (const std::string &expression)
 
virtual ~CacheHandlerIterator ()
 

Protected Member Functions

void GetNextVector ()
 

Protected Attributes

std::vector
< redisclient::RedisValue > 
keys_
 
int index_ = 0
 
std::string cursor_ = ""
 
Type type_
 
bool has_next_ = false
 
- Protected Attributes inherited from granada::cache::CacheHandlerIterator
std::string expression_
 

Static Protected Attributes

static std::unique_ptr
< granada::cache::RedisCacheDriver
cache_
 

Detailed Description

Iterates over cache keys. Tool for SCAN or KEYS search in a Redis database, with a given pattern.

Member Enumeration Documentation

Type of search, SCAN or KEYS

Enumerator
KEYS 
SCAN 

Constructor & Destructor Documentation

granada::cache::RedisIterator::RedisIterator ( )
inline

Constructor.

granada::cache::RedisIterator::RedisIterator ( const std::string &  expression)

Constructor.

Parameters
expressionExpression used to match keys.
                 Example of expression:

                   session:value:*
                   => will retrieve all the keys that start with
                   session:values: stored in the cache.

                   *:value:*
                   => will retrieve all the keys that contain
                   ":value:"
granada::cache::RedisIterator::RedisIterator ( RedisIterator::Type  type,
const std::string &  expression 
)

Constructor

Parameters
typeType of search KEYS or SCAN
expressionFilter pattern/expression. Example: session:TOKEN46464 => will SCAN or KEYS keys that match the given expression.
virtual granada::cache::RedisIterator::~RedisIterator ( )
inlinevirtual

Destructor

Member Function Documentation

void granada::cache::RedisIterator::GetNextVector ( )
protected

Get the next vector with data of SCAN or KEYS

virtual const bool granada::cache::RedisIterator::has_next ( )
virtual

Returns true if there is another value with same pattern, false if there is not.

Returns
True | False

Implements granada::cache::CacheHandlerIterator.

virtual const std::string granada::cache::RedisIterator::next ( )
virtual

Returns the next key found with the given pattern.

Returns
next key in the keys_ vector.

Implements granada::cache::CacheHandlerIterator.

virtual void granada::cache::RedisIterator::set ( const std::string &  expression)
overridevirtual

Set the iterator, useful to reuse it.

Parameters
expressionFilter pattern/expression. Example: session:TOKEN46464 => will SCAN or KEYS keys that match the given expression.

Reimplemented from granada::cache::CacheHandlerIterator.

void granada::cache::RedisIterator::set ( RedisIterator::Type  type,
const std::string &  expression 
)

Set the iterator, useful to reuse it.

Parameters
typeSCAN or KEYS command.
expressionFilter pattern/expression. Example: session:TOKEN46464 => will SCAN or KEYS keys that match the given expression.

Member Data Documentation

std::unique_ptr<granada::cache::RedisCacheDriver> granada::cache::RedisIterator::cache_
staticprotected

Manager of the storage, and contains the data stored.

std::string granada::cache::RedisIterator::cursor_ = ""
protected

If SCAN search the cursor of the SCAN set we are in.

bool granada::cache::RedisIterator::has_next_ = false
protected

True if there is a value to be returned.

int granada::cache::RedisIterator::index_ = 0
protected

Index where we are in the results array.

std::vector<redisclient::RedisValue> granada::cache::RedisIterator::keys_
protected

Results of the SCAN or KEYS search.

Type granada::cache::RedisIterator::type_
protected

Search type: SCAN or KEYS


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