-
Notifications
You must be signed in to change notification settings - Fork 87
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
Postgresql database as Moneta backend ? #92
Comments
|
|
I've added some optimisations to the Sequel adapter in master to use the |
I've now added an hstore implementation too. If you are interested in trying it out, you can do something like: store = Moneta::Adapters::Sequel.new(
db: 'posgres://...',
table: :some_table,
hstore: 'key value')
store['x'] = 'y'
# etc On store creation, a table called :some_table gets added to your database with a string column It all seems to work fine, but its definitely slower in some cases than using a row for every pair. In particular, concurrent writes are extremely slow. Still might be useful in some cases ... |
I wat thinking about adding a dedicated Postgres adapter which could be a bit tighter than the existing ActiveRecord one by leaning on facilities like However, since you've already special-cased Sequel for this, would you consider special-casing ActiveRecord too? |
That being said, I was thinking about this in the context of adding native EDIT: Never-mind, this should be possible, by adding a INSERT INTO moneta (k, v, expire_at)
VALUES ('key', 'v', now() + interval '1 minute')
ON CONFLICT (k)
DO UPDATE
SET v = 'v'
, expire_at = now() + interval '1 minute'
WHERE moneta.expire_at < now(); |
@bjeanes if you were to subclass the ActiveRecord adapter in a similar way to the Sequel adapter, that contribution would very gratefully accepted! |
If I end up doing this work, I will absolutely contribute it back. As it stands, I want to stress test the existing one to make sure it is as resilient as it claims. Performance isn't my immediate concern, but resilience is. That being said, native expires (esp in the context of the mutex API changes discussed in #156) would be excellent. EDIT: But my intention wasn't to use ActiveRecord necessarily, as it's mostly an unnecessary dependency. If special-casing to a specific DB, might as well use the DB driver directly to cut down on dependencies. |
Hi Daniel, all
Moneta seem a superb level of abstraction!
Here minor points, not issues! just feedbacks:
1. Postgresql as relational db supported backend
I read you mention Sqlite3 (with multiprocess limitations you point out in the comparison table)
I suppose I'd use Postgres instead, maybe through the beloved Sequel ORM adapter,
Probably a dedicated Postgres adapter could benefit by the HSTORE (http://www.postgresql.org/docs/9.4/static/hstore.html) or JSONB (http://www.postgresql.org/docs/9.4/static/datatype-json.html) in last release database features, just to store hashes/unstructured data.
I didn't yet read the Sequel code of Moneta Sequel backend adapter but I presume that's generic (not using any specific feature of Posgres); that's correct ?
2. Oj as JSON Moneta::Transformer
I see in the list mentioned Ox (I presume that's Peter Ohler optimizer for XMLs adata)
Do you also foresee superfast Oj (https://github.com/ohler55/oj) as JSON optimizer ?
3. Performances/Benchmarks
Do you pheraps did some performance benchmarks comparing different backends (with disk persistence) ?
BTW, I found interesting this: https://gist.github.com/stephan-nordnes-eriksen/6c9c56f63f36d5d100b2
Sorry for many topics and to not yet browsed the project code
respect
giorgio
The text was updated successfully, but these errors were encountered: