shumkov / rediska Goto Github PK
View Code? Open in Web Editor NEWNo longer maintained. Full-featured PHP client for key-value database Redis
Home Page: http://rediska.geometria-lab.net
License: BSD 3-Clause "New" or "Revised" License
No longer maintained. Full-featured PHP client for key-value database Redis
Home Page: http://rediska.geometria-lab.net
License: BSD 3-Clause "New" or "Revised" License
I was wondering if we should create something like:
class Rediska_InvalidArgumentException extends Rediska_Exception implements InvalidArgumentException
... and start validating inputs on some methods. I think all the get
-methods have a lot of parameters and [sh,c]ould be validated.
Thoughts?
In doc (http://rediska.geometria-lab.net/documentation/integration-with-frameworks/symfony/) integration on symfony 1 - unsupported version
and what about symfony 2 ?
Composer is a very nice tool for managing dependencies.
All that is needed is a composer.json
file and then to register the package on http://packagist.org/
i'm using rediska in a backgorund process after the update from rediska 0.5.1 -> 0.5.7 the process is loosing the connection - with the following exception "Can't read from socket" in Rediska_Connection->readLine()
When using getOptions method on a Rediska instance, returns the default server settings instead of the current server connections.
I'm using new version of Redis, and master branch of Rediska (updated files today)
I noticed that every time I'm pushing message to channel, subscribe script crashed with exception.
PHP Fatal error: Uncaught exception 'Rediska_Connection_TimeoutException' with message 'Connection read timed out.' in /var/www/test/Rediska/Connection.php:226
Stack trace:
#0 /var/www/test/Rediska/Connection/Exec.php(258): Rediska_Connection->readLine()
#1 /var/www/test/Rediska/PubSub/Channel.php(521): Rediska_Connection_Exec::readResponseFromConnection(Object(Rediska_Connection))
#2 /var/www/test/Rediska/PubSub/Channel.php(251): Rediska_PubSub_Channel->_getResponseFromConnection(Object(Rediska_Connection))
#3 /var/www/test/Rediska/PubSub/Channel.php(348): Rediska_PubSub_Channel->getMessage()
#4 /var/www/test/notifications.php(28): Rediska_PubSub_Channel->valid()
#5 {main}
thrown in /var/www/test/Rediska/Connection.php on line 226
Can't understand why this happend, bug in Rediska or maybe something else?
Subscribe code is simple as from Rediska documentation
On line 4 of Rediska/PubSub/Channel.php there is a require_once that is trying to include Rediska.php.
This seems redundant with auto loading - and the path is wrong regardless.
Since the sessions data (stored in the key) has an expiry set, what is the purpose of the sorted set in Rediska_Zend_Session_SaveHandler?
Should be isWritten() ?
CLIENT command for clients introspection.
A lifetime of 'Null' should mean the data never expires. Can I suggest changing the area around line 124 of Rediska/Zend/Cache/Backend/Redis.php to read:
if ($result && $lifetime) {
$this->_rediska->expire($id, $lifetime);
}
Hello, Ivan.
I propose make better usage of autoload. Rename Rediska
to Rediska_Env
(or smth else, but need prefix Rediska_
). I think that better when all files located in one folder
I am using rediska plugin for session management but when sessoin is expired, redis session key remains on redis server.
How can I delete the expired session keys in rediska plugin?
There is any garbage collection present in rediska plugin? If so then how it is working?
Example code:
$channel = $this->rediska->subscribe('bets', $sleeptime);
$channel->unsubscribe();
This will cause:
PHP Fatal error: Uncaught exception 'Rediska_PubSub_Exception' with message 'Can't find connection 'localhost:6379'' in /Users/fern/workspace/golpas2pg/share/PEAR/Rediska/PubSub/Connections.php:167
Stack trace:
#0 /Users/fern/workspace/golpas2pg/share/PEAR/Rediska/PubSub/Channel.php(462): Rediska_PubSub_Connections->getConnectionByAlias('localhost:6379')
#1 /Users/fern/workspace/golpas2pg/share/PEAR/Rediska/PubSub/Channel.php(148): Rediska_PubSub_Channel->_execCommand('unsubscribe', Array)
#2 /Users/fern/workspace/golpas2pg/share/lib/Gp/Casino/Roulette/Daemon/Run.php(184): Rediska_PubSub_Channel->unsubscribe()
If you do not do unsubscribe()
, subscribe connection will nor be closed and you will get "too many files open" in several hours (depending on your sleeptime).
Here is the fix on code:
Channel.php:462
if (!$connection)
$connection = $this->_connections->getConnectionByAlias($connectionAlias);
Channel.php:471
if (!$connection)
$connection = $this->_connections->getConnectionByAlias($connectionAlias);
There was an error because with unsubscribe the channel is removed from arrays with previous line
$connection = $this->_connections->removeChannel($channel);
and getConnectionByAlias can not find it (it is already removed).
$connection is returned by methods and there is no need to search for it again.
Sometimes I find the following error in our error log. I'm using Rediska 0.5.6. I wasn't able to reproduce this error on purpose yet. In a way this should not be possible as Rediska_Zend_Session_Set implements ArrayAccess. Do you have an idea how to resolve this issue?
[30-Nov-2011 12:21:53] PHP Fatal error: Cannot use object of type Rediska_Zend_Session_Set as array in ../libs/Rediska/Zend/Session/SaveHandler/Redis.php on line 137
В множестве Rediska_Key_Set имеется больше 100000 записей.
$set=new Rediska_Key_Set('myset');
foreach ($set as $value)
{
//do something
}
Такой код вызывает ошибку - не хватает памяти для обработки скрипта.
Можно ли "поштучно" перебрать всё множество?
I discovered this when using getKeysByPattern, which serves a REPLY_MULTY_BULK response.
Currently, if there are no matching keys in the response, an empty array is returned for each connection (as defined on line 235 in Command/Abstract.php).
This causes a warning on line 39 of GetKeysByPattern as explode is expecting a string and is instead met with an array.
Perhaps the solution is the following in Abstract.php (line 228):
case self::REPLY_MULTY_BULK:
$count = (integer)$data;
if ((string)$count != $data) {
throw new Rediska_Command_Exception("Can't convert multi-response header '$data' to integer");
}
if ($count) {
$replies = array();
for ($i = 0; $i < $count; $i++) {
$replies[] = $this->_readResponseFromConnection($connection);
}
return $replies;
} else {
return null;
}
Hope this helps,
Ryan
Hey guys - you're probably aware of this already, but this command subset is currently missing from Expire.php.
Thanks,
Ryan
That makes it super easy to install with Composer.
Finally many write commands are able to take multiple values! This is the full list:
SADD set val1 val2 val3 ... -- now returns the number of elements added (not already present).
HDEL hash field2 field3 field3 ... -- now returns the number of elements removed.
SREM set val1 val2 val3 ... -- now returns the number of elements removed.
ZREM zset val1 val2 val3 ... -- now returns the number of elements removed.
ZADD zset score1 val1 score2 val2 ... -- now returns the number of elements added.
LPUSH/RLPUSH list val1 val2 val3 ... -- return value is the new length of the list, as usually.
Since Redis ability to process commands faster is not usually related to the time needed to alter the data set, but to the time spent into I/O, dispatching, sending the reply back, this means that now for some applications there is some impressive speed improvement.
Есть редис на хосте cache1.com:6379. Поставил Twemproxy на 127.0.0.1:6379, пишет:
Rediska_Connection_Exception' with message 'Can't read from socket. tcp://127.0.0.1:6379
Код:
$options = array(
'namespace' => 'dd_',
'servers' => array(
array('host' => '127.0.0.1', 'port' => 6379),
// array('host' => 'cache1.com', 'port' => 6379),
),
);
$rediska = new Rediska($options);
$rediska->set('XXX', date('Y-m-d H:i:s'));
Кто-то пробывал использовать Twemproxy + Rediska?
I did it in myself, but better if Rediska also will have it :)
why not?
$command = array($revert ? 'ZREVRANGEBYSCORE' : 'ZRANGEBYSCORE',
$this->_rediska->getOption('namespace') . $key,
$min,
$max);
in getFromSortedSetByScore()
I keep getting the following error. It's random though - sometimes happens, sometimes now.
[08-Apr-2010 11:55:38] PHP Fatal error: Access to undeclared static property: Rediska::$_writeClosed in Unknown on line 0
[08-Apr-2010 11:55:38] PHP Stack trace:
[08-Apr-2010 11:55:38] PHP 1. {main}() /home/till/example.org/www/index.php:0
[08-Apr-2010 11:55:38] PHP 2. Zend_Controller_Front->dispatch() /home/till/example.org/www/index.php:28
[08-Apr-2010 11:55:38] PHP 3. Zend_Controller_Dispatcher_Standard->dispatch() /home/till/example.org/library/Zend/Controller/Front.php:954
[08-Apr-2010 11:55:38] PHP 4. Zend_Controller_Action->dispatch() /home/till/example.org/library/Zend/Controller/Dispatcher/Standard.php:289
[08-Apr-2010 11:55:38] PHP 5. ApiController->postDispatch() /home/till/example.org/library/Zend/Controller/Action.php:517
[08-Apr-2010 11:55:38] PHP 6. Zend_XmlRpc_Server->handle() /home/till/example.org/app/modules/default/controllers/ApiController.php:184
[08-Apr-2010 11:55:38] PHP 7. Zend_XmlRpc_Server->_handle() /home/till/example.org/library/Zend/XmlRpc/Server.php:337
[08-Apr-2010 11:55:38] PHP 8. Zend_Server_Abstract->_dispatch() /home/till/example.org/library/Zend/XmlRpc/Server.php:599
[08-Apr-2010 11:55:38] PHP 9. call_user_func_array() /home/till/example.org/library/Zend/Server/Abstract.php:219
[08-Apr-2010 11:55:38] PHP 10. Model_XmlRpc_User::searchUser() /home/till/example.org/library/Zend/Server/Abstract.php:0
[08-Apr-2010 11:55:38] PHP 11. ez_User->searchUser() /home/till/example.org/app/modules/default/models/XmlRpc/User.php:566
[08-Apr-2010 11:55:38] PHP 12. Zend_Db_Table_Abstract->fetchAll() /home/till/example.org/library/ez/User.php:151
[08-Apr-2010 11:55:38] PHP 13. Zend_Db_Table_Abstract->_fetch() /home/till/example.org/library/Zend/Db/Table/Abstract.php:1321
[08-Apr-2010 11:55:38] PHP 14. Zend_Db_Statement->fetchAll() /home/till/example.org/library/Zend/Db/Table/Abstract.php:1506
[08-Apr-2010 11:55:38] PHP 15. Zend_Db_Statement_Mysqli->fetch() /home/till/example.org/library/Zend/Db/Statement.php:341
[08-Apr-2010 11:55:38] PHP 16. Rediska_Zend_Session_SaveHandler_Redis->__destruct() /home/till/example.org/library/Rediska/Zend/Session/SaveHandler/Redis.php:0
[08-Apr-2010 11:55:38] PHP 17. Zend_Session::writeClose() /home/till/example.org/library/Rediska/Zend/Session/SaveHandler/Redis.php:110
Like the title says. I can't seem to add multiple members to a set in one command with rediska. I'm not really sure how I would implement it either. I tried to change the serializer to "toString" and that didn't work.
in Connection.php, when calling stream_socket_client(), the last parameter is calling $this->getStreamContext(), which return null always, then happens this error:
Rediska_Connection_Exception' with message 'Can't connect to Redis server on 127.0.0.1:6379
After removed "@" from "$this->_socket = @stream_socket_client("
the warning is this:
Warning: stream_socket_client() expects parameter 6 to be resource, null given
When I removed this parameter from stream_socket_client, it worked!
The Rediska_Serializer_Adapter_Json::unserialize method is returning the same value that is being passed in to be unserialized. Please see below:
Lines 88-97
public function unserialize($value)
{
$decodedValue = json_decode($value);
if ($decodedValue === null && $value !== 'null') {
throw new Rediska_Serializer_Adapter_Exception("Can't unserialize value");
}
return $value;
}
The last line should, instead be "return $decodedValue;".
public function unserialize($value)
{
$decodedValue = json_decode($value);
if ($decodedValue === null && $value !== 'null') {
throw new Rediska_Serializer_Adapter_Exception("Can't unserialize value");
}
return $decodedValue;
}
I'm getting errors in log:
PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in Rediska/Connection.php on line 358.
Earlier I had memory_limit 128Mb and had the same issues.
Any recommendations?
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.