yiisoft / yii2-redis

Yii 2 Redis extension.
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
451 stars 183 forks source link

RedisActiveRecord expire time #74

Open NaLLiFFuNT opened 8 years ago

NaLLiFFuNT commented 8 years ago

ActiveRecord expire

RedisActiveRecod does not have ability to be stored with some expire time.

What's expected?

Add method to RedisActiveRecod ttl() wich return time to live value in seconds. Every time when we will save or update model, we will apply expire command with this value to AR's keys. If ttl() method return false expire command doesn't have to be applied.

nailfor commented 8 years ago

Hello , NaLLiFFuNT I let fork, where added to the TTL and EXPIRE for REDIS records See https://github.com/nailfor/yii2-redis Be aware, that fork incompatible with current keypool

thiagotalma commented 7 years ago

Hello @nailfor How about doing a PR to share your code with the community?

nailfor commented 7 years ago

Hello @thiagotalma i'm don't know how do it)) I written redis extension about 5 month ago and only 2-3 peoples downloaded it from packagist.org

thiagotalma commented 7 years ago

@nailfor It's because people do not want to download a parallel extension. They only download the official one.

What you need to do is to rebase the master branch of that repository and open a PULL REQUEST to request that your modifications be incorporated into the official extension.

nailfor commented 7 years ago

@thiagotalma ok, but my extension incompatible with the official keypool, because I used SADD to create unique keys, not RPUSH To work with an existing database, you must first convert the key pool like this redis-cli -n 0 LRANGE 'rd_user 0 -1 | awk' {print $ 1} '| xargs redis-cli -n 0 SADD rd_user_temp Therefore, I doubt that it will be able to add to the official thread

zacksleo commented 7 years ago

Same question. Someone can help?

nailfor commented 7 years ago

@zacksleo see that: https://github.com/nailfor/yii2-redis/blob/master/EXAMPLES.md

pleasereachmeoutonmoeinxyz commented 7 years ago

@cebe Yii community need it strongly.

cebe commented 7 years ago

its hard to implement this because it would require redis to support TTL on items in a list, so a pk can be deleted from the PK lookup. Afaik this is not supported.

nailfor commented 7 years ago

Of course это хард ту имплемент... При использовании RPUSH (in current version) возникают сложности отслеживания и работы с пулом ключей. Перебор ключей внешними средствами - долгая задача(но вполне реальная), гораздо быстрее сделать это средствами самого redis, у которого для этих целей есть метод SADD. Основная идея очень простая:

samdark commented 7 years ago

@nailfor it's better not to mix languages :)

nailfor commented 7 years ago

@samdark as you wish