Coder Social home page Coder Social logo

redis's Introduction

redis's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redis's Issues

Redis 3.0

  • nastudovat changelog
  • najít a pořešit BC Breaky
  • Travis build pro 2.8 i pro 3.0
  • otagovat master pro Nette 2.3

keys to scan in RedisJournal

In RedisJournal::clean there is used keys Redis command. What about to replace it to more performant scan? I can create PR if you will agree with the change.

Thanks

Problem with loading from cache

Hi,

I`m trying to use Redis cache for address suggestion at Nette.

When I save array result like, where $suggestions is array:

$cache->save($key, Json::encode($suggestions), [
    Cache::TAGS    => [self::ADDRESS_SUGGESTION_KEY],
    Cache::EXPIRE  => self::ADDRESS_SUGGESTION_EXPIRATION,
    Cache::SLIDING => TRUE,
]);

and load them
$suggestions = $cache->load($key);

I get array (count = 1) with index 0 and value:

\x00\x00\x02\x12\x01>{"time":"0.84394800 1449592378","delta":31622400}\x00["Jind\xc5\x99icha Plachty, Praha, \xc4\x8cesk\xc3\xa1 repub...

What are these chars \x00\x00\x02\x12\x01> for? I can`t unserialize, decode or do something else with them.

Don`t you know, where the problem is?

Thank you.

RedisStorage: Unsupported operand types

On this line I sometimes get Fatal Error Unsupported operand types.

In debugger I see following values:

$key = 'Kdyby.Autowired.AutowireProperties 6c0ef3504d5a554fb419842d8047550c';

$data = 'a:7:{s:9:"webLoader";a:2:{s:5:"value";N;s:4:"type";s:29:"WebLoader\Nette\LoaderFactory";}s:14:"systemSettings";a:2:{s:5:"value";N;s:4:"type";s:28:"Libs\Settings\SystemSettings";}s:15:"companySettings";a:2:{s:5:"value";N;s:4:"type";s:29:"Libs\Settings\CompanySettings";}s:11:"webSettings";a:2:{s:5:"value";N;s:4:"type";s:25:"Libs\Settings\WebSettings";}s:12:"imageManager";a:2:{s:5:"value";N;s:4:"type";s:30:"Libs\System\Image\ImageManager";}s:12:"modalManager";a:2:{s:5:"value";N;s:4:"type";s:24:"Libs\Modals\ModalManager";}s:11:"menuFactory";a:2:{s:5:"value";N;s:4:"type";s:26:"DK\Menu\UI\IControlFactory";}}";';

$meta = 's:1102:"{"time":"0.67322700 1450782047","callbacks":[[["Nette\\Caching\\Cache","checkFile"],"\/home\/vagrant\/Code\/xxxxxxxxxxxxxxxx\/App\/Presenters\/BasePresenter.php",1450445442],[["Nette\\Caching\\Cache","checkFile"],"\/home\/vagrant\/Code\/xxxxxxxxxxxxxxxx\/App\/RealEstateModule\/Presenters\/ListPresenter.php",1448030539],[["Nette\\Caching\\Cache","checkFile"],"\/home\/vagrant\/Code\/xxxxxxxxxxxxxxxx\/temp\/cache\/Nette.Configurator\/Container_e92ce85e6e.php",1450781946]],"serialized":true}';

$storedValue = 's:1102:"{"time":"0.67322700 1450782047","callbacks":[[["Nette\\Caching\\Cache","checkFile"],"\/home\/vagrant\/Code\/xxxxxxxxxxxxxxxx\/App\/Presenters\/BasePresenter.php",1450445442],[["Nette\\Caching\\Cache","checkFile"],"\/home\/vagrant\/Code\/xxxxxxxxxxxxxxxx\/App\/RealEstateModule\/Presenters\/ListPresenter.php",1448030539],[["Nette\\Caching\\Cache","checkFile"],"\/home\/vagrant\/Code\/xxxxxxxxxxxxxxxx\/temp\/cache\/Nette.Configurator\/Container_e92ce85e6e.php",1450781946]],"serialized":true} a:7:{s:9:"webLoader";a:2:{s:5:"value";N;s:4:"type";s:29:"WebLoader\Nette\LoaderFactory";}s:14:"systemSettings";a:2:{s:5:"value";N;s:4:"type";s:28:"Libs\Settings\SystemSettings";}s:15:"companySettings";a:2:{s:5:"value";N;s:4:"type";s:29:"Libs\Settings\CompanySettings";}s:11:"webSettings";a:2:{s:5:"value";N;s:4:"type";s:25:"Libs\Settings\WebSettings";}s:12:"imageManager";a:2:{s:5:"value";N;s:4:"type";s:30:"Libs\System\Image\ImageManager";}s:12:"modalManager";a:2:{s:5:"value";N;s:4:"type";s:24:"Libs\Modals\ModalManager";}s:11:"menuFactory";a:2:{s:5:"value";N;s:4:"type";s:26:"DK\Menu\UI\IControlFactory";}}";'

Problem is with that $meta being serialized json string, which json_decode($meta, true) evaluates as null.

This happens about once or twice per week, clearing cache helps. I didn't find a way to reproduce this. As there is no production version yet, I can't tell whether it may be caused by another error or something.

PHP 8 Compatibility

After running composer update in a nette project with PHP 8 I've got the following error:
kdyby/redis v5.1.0 requires php ^7.1 -> your php version (8.0; overridden via config.platform, actual: 7.4.11) does not satisfy that requirement.

Redis version not enforced

Failed to successfully execute lua script journal.clean(): ERR unknown command 'EVALSHA'

Evalsha is available since 2.6.0. Having a config compile time check should not have any meaningful performance impact

Support for pipelining

Do you plan to support it?

I just tried to use it on pure Redis class and performance got 20x better. See source.

Also this issue in phpredis is useful.

I found this disadvantage of pipelining:

It's not that retrieval operations aren't working, it's just that you
are queueing them up in the pipeline which means that you won't be
able to get the results until you read the stream of replies back from
Redis. Pipelining can be applied only in certain scenarios, for
example you can't perform conditional operations while pipelining (at
least not without using a second connection).

I tried to implement it but with no success.

Incompatible declarations of Redis::connect() and Redis::script()

I have an issue on my environments. ATM I have Kdyby/Redis 4.0.0. and installed redis v4.0.6 (macOS) and I gets 2 errros:

PHP Warning: Declaration of Kdyby\Redis\Driver\PhpRedisDriver::connect($host, $port = NULL, $timeout = 0) should be compatible with Redis::connect($host, $port, $timeout = NULL, $retry_interval = NULL) in .../redis/src/Kdyby/Redis/Driver/PhpRedisDriver.php:21

PHP Warning: Declaration of Kdyby\Redis\Driver\PhpRedisDriver::script($command, $script = NULL) should be compatible with Redis::script($cmd, ...$args) in .../redis/src/Kdyby/Redis/Driver/PhpRedisDriver.php:21

On redis v4.0.0 (ubuntu) is it ok as on v3.2.100 (windows).

Note that PHP Storm have another implementations :-/

public function connect( $host, $port = 6379, $timeout = 0.0, $reserved = NULL, $retry_interval = 0)

Related topis https://forum.nette.org/cs/29379-kompatibilita-kdyby-redis-connect

Configuration behaviour on v6.0

On the v6.0 I have found some config issues and reported in #106 which solved @PavelJurasek and merged by @Vboss

It looked it's working fine, but finally yesterday I was setting this new version from our local development to staging and production and I have found some other issues:

In some cases, when you specify a different database then it looks like it's creating another connection, but it does not take other values like auth and host:

redis:
    host: localhost
    port: 6379
    auth: hash_key
    database: 0
    journal: true
    storage: true
    session:
        database: 1
        auth: hash_key
    debugger: true

If I don't specify auth - it's dying on the exception Client of tcp://127.0.0.1:6379; ERR Client sent AUTH, but no password is set, but when I debug the Client, I saw that the normal client has all the credentials, but other with database1 has no hash, if I specified it, it works.

This is the behavior on our staging and local VM on Ubuntu, where we have all on one server. On the live infrastructure, where we have several web instances and one Redis server it works without the necessary auth under session, but we have no localhost, but internal DNS record to sey-www-prod-redis.

But interesting was that first I set the config the same way on staging and I got another exception: Nette\InvalidStateException: Failed to read session data: redis (path: tcp://127.0.0.1:6379?weight=1&timeout=10&database=1&prefix=Nette.Session%3A&auth=authhash. When I removed the auth from the session, it works. So here it looks like it does not take the host from the main configuration, but only when auth is set. The working config on the live server is:

redis:
    host: sey-www-prod-redis
    port: 6379
    auth: hash_key
    database: 2
    journal: true
    storage: true
    session:
        database: 1
    debugger: true

Until the v5.2 it worked all fine. The main idea is to have separate sessions and with deployment, we can clean the application cache.

RedisException: Redis server went away after upgrade to v 6.0.0

After upgrade from v5.2.0 to v 6.0.0 - RedisException: Redis server went away
Same config as before (last php 8.0, last redis client, nette 3.0)

In RedisExtension.php there is protected function loadSession.
$sessionConfig['host'] is set always to default '127.0.0.1' even if I have Redis in another container.

[RFC] fastest mother-fucking journal ever

Inspiration: Cache – FileStorage without FileJournal with TAGS support – working solution


Let's not delete the cache on invalidation and just let it rot untill it's deleted by itself or flushed on deployment. Let's say we instead of deleting the keys in database on invalidation, set some value that would mean some TAG was invalidated at that given time.

On read, there would be always check (there could be lua script doing this saving bandwidth) that the key has tags and if it has tags, than there would be check when was the last time the tag was deleted and if the cache entry is older then the flushing by tag, no value would be returned but instead the one entry will be deleted.

Garbage collection could be done using maxmemory=volatile-ttl as stated in #20


someone must:

  • impelement proof-of-concept
  • test it on hight traffic site

Wait for BUSY

Wait for blocking script to finish

Kdyby\Redis\RedisClientException

BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.

Config issue on v6.0.0-rc2

I tested today v6.0.0-rc2 and an xception was thrown:

Screenshot 2021-08-25 at 16 55 05

Which corresponds to my config in local.neon:

redis:
    host: localhost
    port: 6379
    database: 0
    journal: true
    storage: true
    session:
        database: 1
        native: false
    debugger: true

The previous version didn't throw an exception on this, are there any config changes, or is it the bug?

Support for redis cluster and/or version that's compatible with twemproxy

I really like this package, but it's not possible to use it with cluster, at least I did not find an option to use it against partitioned redis, Currently I saw two good enough options for sharding redis.
One is using twemproxy, which does not support all redis commands, like multi or select.
Other option is to use redis cluster but client has to support redis cluster (handle redirection).
Any chance for some support? Without this plugin sadly isn't usable on any horizontally scaled redis infrastructure.
Maybe some other idea?

separate the client from the extension

i really like your client and i'm using it in some of my libraries. but the libraries can be used without nette, but this lib requires some nette parts, which are not really required for the client, thus it forces the users of my lib to download these nette packages.

i think the client can stand on its own and the extension should just require the client

Return type of RedisSessionHandler::gc doesn't match the interface

Since the library requires >= PHP 7.4, shouldn't the return type of RedisSessionHandler::gc match the int|false of SessionHandlerInterface::gc? Now it throws deprecated error.
Return type of Kdyby\Redis\RedisSessionHandler::gc($maxLifeTime): bool should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Implement isConnected method

Class Kdyby\Redis\Driver\PhpRedisDriver contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Kdyby\Redis\IRedisDriver::isConnected)

Remove dependency on nette/deprecated package

This extension is dependent on package nette/deprecated. It would be useful to update it to use up-to-date class names.

I found \Nette\Diagnostics\Debugger instead of \Tracy\Debugger in RedisSessionHandler.

Nette 2 vs. 3

Hi there,

I just wanted to ask what is the reason for this:

"nette/di": "~2.4.10 || ~3.0",
"nette/caching": "~3.0",
"nette/http": "~2.4.7 || ~3.0",
"nette/utils": "~2.5 || ~3.0",

I mean why is nette/caching required in 3.0 while the others still allow 2.4/5?

We have a project with nette 2.4 (and still quite some work before we can move to 3.0).
nette/database is on 2.4.8 which requires nette/caching ^2.2 which is then a conflict.

So my question is: Is nette/caching really needed in 3.0 or would ^2.4 be also acceptable? If it could work with 2.4, I would like to ask to change the composer.json accordingly.

As a side note, I want to point out the difference between ~ and ^ in the versioning syntax and suggest that ^ is preferred. I think we were actually having this discussion in some other kdyby package issue already...

Just to provide a bigger picture. This conflict is preventing me right now from upgrading PHP to 7.4 prior to upgrading nette to 3.0. And i believe if nette/caching was required as ^2.4 || ^3.0 I could then upgrade PHP before nette. Question is whether kdyby/redis 5.0 can actualy work with nette/caching ^2.4?

If you have no idea about the reasoning, I am willing to try it out on my own, but I'd first like to get some insight from you, guys.

Thanks in advance.

Multiple storages configuration

Allow to create multiple storages tu utilize more databases, therefore making it easier to flush cache on deploy.

Might work as this

redis:
    additional:
        translator: 0

services:
   translator: App\Translator(@redis.additional.translator)

It would create additional not-autowired instance of RedisClient, and also storage+journal, under service name @redis.additional.translator would be the storage ready to be used.

Redis server went away

Question: Shoud it try to reconnect?

Kdyby\Redis\RedisClientException

Redis server went away

add a way to get the driver

i'm using Doctrine's RedisCache which needs an instance of the Redis class. to keep the configuration at one place and use only one instance of redis driver it would be great if the redis client had a getter for the driver.

or make your client accept a redis driver in constructor.

Setting different db

This is my config:

redis:
    session: {database: 0, native: off}
    storage: {database: 1}
    journal: {database: 2}

Everything works, except that storage is as well saved to database 0 instead of 1?
screenshot_1
Any info?

Max cache life expectancy

Redis has an option for automatic garbage collection.

If all keys written by storage and journal had expiration (for let's say a month), the option maxmemory=volatile-ttl could be used for automatic garbage collection of old cache. As a result, the oldes cache would be removed automatically and the most fresh will survive.

Socket connection: type error

If i use socket connection:

redis:
    host: '/tmp/redis.sock'

There is an error:

TypeError
Argument 2 passed to Kdyby\Redis\RedisClient::__construct() must be of the type int, null given, called in /Users/karelborkovec/Develop/Web/freelo/vendor/kdyby/redis/src/Kdyby/Redis/DI/RedisExtension.php on line 300

It's because of this line of code. And if this is a socket connection it should be reflected here.
What do you think?

user_script:2: attempt to concatenate local 'key' (a userdata value)

[2013-08-19 00-47-46] Kdyby\Redis\RedisClientException: 
Failed to successfully execute lua script journal. write(52269f3d9677595df378c6fbe2e4a8b3): 
ERR Error running script (call to f_3ccea2cb2eb0750385a970f54c13ceee756d6369): 
user_script:2: attempt to concatenate local 'key' (a userdata value) 
in /vendor/kdyby/redis/src/Kdyby/Redis/RedisLuaJournal.php:79

Implementation of Nette/Caching/BulkReader

At this moment, there is an implementation of Redis mget (get multiple keys via one command) with interface IMultiReadStorage. Latest version (2.5) of Nette\Caching has similar posibility in https://github.com/nette/caching/blob/master/src/Caching/BulkReader.php. The possibility has been there since v2.2.

This could improve reading from Redis and decrease an amount of get calls.

Some additional information why to use mget:

Fatal error: Invalid serialization data *

in method RedisStorage::getUnserializedValue, it should be possible to handle possible errors without crashing the whole app

return @unserialize($stored[1]); // intentionally @

could be encapsuled in try {} catch (Throwable $t) {} - to catch it and log it at least in php7 (7.1 alpha 3 +)

we are currently dealing with error "Invalid serialization data for DateTime object", and want to discuss possible/best solutions for this, so we cant fork it then, test in production and send pull request

thanks

(only way to reproduce it we have come up with is this:

php

Support for igbinary serialize/unserialize

You're thinking about implementation igbinary for serialize/unserialize function (at least in optional or autodetect) ?
My tests showing better resolution in execution time and memory consumption.
(for huge array)
Serialize: 1245.229ms
serialize string strlen 34572639
Unserialize: 2040.023ms

IGBinary Serialize: 492.500ms
serialize string strlen 5736402
IGBinary Unserialize: 837.035ms

Sessions are lost between requests

Hi,

we are using kdyby/redis (commit 7940937) in our eshop system. Now, we are realized that sessions is lost in some cases.

We are able to simulate situation when session is lost, but I have no idea how to debug whats wrong. We have tried both native and emulated driver.

Situation is following - we open product detail in annonymous tab, add product to basket, but when I go to the basket, product is lost, it's happens for almost every try.

Read error on connection

Question: should it try to reconnect and read it again?

Kdyby\Redis\RedisClientException

read error on connection

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.