phpnode / yiiredis Goto Github PK
View Code? Open in Web Editor NEWA set of wrappers for different data types in redis
A set of wrappers for different data types in redis
i have promlem
PHP Error[2048]: Only variables should be passed by reference
in file /var/www/***/app/lib/vendor/codemix/yiiredis/ARedisIterableEntity.php at line 29
php -v
PHP 5.5.3-1ubuntu2.6 (cli) (built: Jul 7 2014 16:54:53)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with XCache v3.1.0-dev, Copyright (c) 2005-2013, by mOo
with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
with XCache Optimizer v3.1.0-dev, Copyright (c) 2005-2013, by mOo
with XCache Cacher v3.1.0-dev, Copyright (c) 2005-2013, by mOo
with XCache Coverager v3.1.0-dev, Copyright (c) 2005-2013, by mOo
use:
$user = new ARedisHash('user.'.$userResourceId);
$out[]=$user->toArray();// ->getData()
Really just a very small thing, but after trying out the examples I got this error message "Redis server went away". This is because the default port is 6379, not 6739. You may want to change that :)
public function getCount() {
if ($this->_count === null) {
if ($this->name === null) {
throw new CException(get_class($this)." requires a name!");
}
$this->_count = (int) $this->getConnection()->getClient()->lSize($this->name);
}
return $this->_count;
}
lSize does not work
but work this:
$rconn = Yii::app()->redis->getClient();
$llen_f = $rconn->llen($redis_key);
Is that a bug?
When used to store Yii 1 sessions with Redis 7.2, i receive the error "Method Redis::delete() is deprecated".
/var/www/protected/extensions/YiiRedis/ARedisSession.php(80)
78 public function destroySession($id)
79 {
80 $this->_connection->getClient()->delete($this->calculateKey($id));
81 return true;
82 }
Replacing the delete() with del() fixes the issue
In class ARedisConnection method getClient() should be,
public function getClient()
{
if ($this->_client === null) {
$this->_client = new Redis;
$this->_client->connect($this->hostname, $this->port);
$this->_client->select($this->database);
}
return $this->_client;
}
This will allow to select different Redis DB from default one; which can be done using following in your main config file,
array(
......
'components'=>array(
......
'redis' => array(
'class' => 'ext.redis.ARedisConnection',
'hostname' => '127.0.0.1',
'port' => 6379,
'database' => 2, //this will select databse 2 [Redis allows to select upto 16]
),
'cache' => array(
'class' => 'ext.redis.ARedisCache'
),
.....
)
);
$channel = new ARedisChannel("myChannel");
$channel->onReceiveMessage = function($redis, $channel, $message) {
echo "Message Received:".$message."\n";
};
$channel->subscribe();
I can't get the value of $channel, $message
24 line
if (!$this->getConnection()->getClient()->hset($this->name,$key, $value))
it don't corrent than hset return 1 if create new 0 if update exist and return false if error
correct code
if (false === $this->getConnection()->getClient()->hset($this->name,$key, $value)) {
Storing and Retrieving simple keys
Yii::app()->redis->getClient()->set("myKey", "Your Value");
echo Yii::app()->redis->getClient->get("myKey");
Yii::app()->redis->getClient()->rem("myKey");
right way: getClient(), del
In the ARedisCache class, line 118, where is calling:
return (bool) $this->getConnection()->getClient()->flush();
it should call:
return (bool) $this->getConnection()->getClient()->flushAll();
populateRecord
$record->setScenario('update');
+$record->setIsNewRecord(false);
$record->init();
getPrimaryKey
foreach($attribute as $field) {
P.S. I do not speak English
Can you please tell us is their any find and findAll related function available in ARedisRecord.php as in Cactiverecord class?
Hi,
I'd like to separate data in different databases, in particular sessions from data, say respectively into database 1 and 2.
I noticed you can instantiate any RedisEntity by specifying a connection, so in principle I can do that. However, I'd find more usable/less error prone to setup the default connection for data, and configure session to use another connection.
A proposal follows, please let me know if you'd like a pull request.
E.
changes to ARedisSession.php
public $connection = null;
/**
* Initializes the application component.
* This method overrides the parent implementation by checking if redis is available.
*/
public function init()
{
if ($this->connection !== null)
$this->setConnection($this->connection);
else
$this->getConnection();
parent::init();
}
- example of main/config.php
```php
'redis' => array(
'class' => 'ext.redis.ARedisConnection',
'hostname' => 'localhost',
'database' => 2,
'port' => 6379,
),
'redis-session' => array(
'class' => 'ext.redis.ARedisConnection',
'hostname' => 'localhost',
'database' => 1,
'port' => 6379,
),
'session' => array(
'class' => 'ext.redis.ARedisSession',
'connection' => 'redis-session',
),
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.