Leon Dang <ldang@nahannisys.com> wrote:
>
> Andreas Kretschmer wrote on 01/28/2015 03:36 AM:
>> > I've implemented a completely new Redis FDW module which has little to do with
>> > github.com/pg-redis-fdw/redis_fdw; although I did take some inspiration from in
>> > on how the tables were to be designed but most I got from looking at the
>> > oracle-fdw.
>> >
>> > My redis-fdw implementation supports read and write to the Redis backend, so
>> > you can do insert, update, and delete. e.g. you can define a hash table as:
>>
>> is it possible to write multiple row's into the redis? something like
>>
>> insert into foreign_redis_table select * from big_table
>>
>
> Thanks for pointing this out. I had a small bug which didn't let it
> succeed, but now it's been fixed and committed; I've also added a
> bulkdata.sql test script in the code to show an example.
Yeah, it's working now:
test=*# insert into test_redis select 'key'||s::text, 'value_xxx'||s::text from generate_Series(1,10) s;
INSERT 0 10
Time: 1,041 ms
test=*# select * from test_redis where key = 'key7';
key | value
------+------------
key7 | value_xxx7
(1 row)
>
>> Anyway, thx, compiled and installed (just for fun, i'm not familiar with
>> redis, and i'm not a coder)
>>
>
> Redis is great for session management as it allows you to set an expiry
> for each key. So by using redis_fdw, you don't need to do multiple
> queries to determine of the session is still valid. e.g.:
Yeah, or as a fast cache, and you can set or update the redis-cache via
trigger:
test=# create table redis_source (key text, val text);
CREATE TABLE
Time: 4,365 ms
test=*# create or replace function redis_update() returns trigger as
$$begin insert into test_redis values (new.key, new.val); return new;
end; $$language plpgsql;
CREATE FUNCTION
Time: 0,532 ms
test=*# create trigger trg_redis after insert or update on redis_source
for each row execute procedure redis_update();
CREATE TRIGGER
Time: 0,439 ms
test=*# insert into redis_source values ('new_key','new_value');
INSERT 0 1
Time: 0,809 ms
test=*# select * from test_redis where key = 'new_key';
key | value
---------+-----------
new_key | new_value
(1 row)
Time: 0,615 ms
test=*# update redis_source set val = 'hot new val' where key =
'new_key';
UPDATE 1
Time: 0,630 ms
test=*# select * from test_redis where key = 'new_key';
key | value
---------+-------------
new_key | hot new val
(1 row)
Nice!
Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°