Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RedisActiveRecord expire time #74

Open
NaLLiFFuNT opened this issue Jun 23, 2016 · 12 comments
Open

RedisActiveRecord expire time #74

NaLLiFFuNT opened this issue Jun 23, 2016 · 12 comments
Labels
status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement

Comments

@NaLLiFFuNT
Copy link

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.

@cebe cebe added the type:enhancement Enhancement label Jun 23, 2016
@nailfor
Copy link

nailfor commented Aug 19, 2016

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
Copy link

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

@nailfor
Copy link

nailfor commented Jan 23, 2017

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
Copy link

@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
Copy link

nailfor commented Jan 23, 2017

@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
Copy link
Contributor

Same question. Someone can help?

@nailfor
Copy link

nailfor commented May 17, 2017

@pleasereachmeoutonmoeinxyz

@cebe
Yii community need it strongly.

@samdark samdark added the status:ready for adoption Feel free to implement this issue. label Jun 17, 2017
@cebe
Copy link
Member

cebe commented Jun 20, 2017

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
Copy link

nailfor commented Jun 21, 2017

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

  • вместо "support TTL on items in a list by redis" я создаю или добавляю в пул ключей командой SADD
  • устанавливаю значения командой HMSET
  • применяю к обоим(пулу и ключу) команду EXPIRE
    Имя пула строится по принципу $prefix:e:$time, где $prefix - имя модели, а $time - время, когда ключ будет удален. Таким образом получается минимум две записи на ключ и пул сгруппированные по одной временной метке. Когда наступит час Х оба ключа будут удалены автоматически.
    So afaik it is already supported in my forge.

@samdark
Copy link
Member

samdark commented Jun 21, 2017

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

@nailfor
Copy link

nailfor commented Jun 21, 2017

@samdark as you wish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

7 participants