./redis-server --loadmodule /path/to/redisql.so
radixis quite simple to use a pooled connection to Redis, indeed
NewPoolfunction that creates a pool of connection to Redis. Then it is possible to use that pool as a client and have the library allocate a client for us.
idof each item we are getting from HN, along with the author of the item, when the item was posted and finally the last field will contains the whole item as a
itemIdschannel that is later consumed.
getMaxItem()function implemented as:
itemIdschannel. For each new item we use again the HN API to get the content of the items and then we store it into RediSQL.
getitem()functions implement a trivial error recovery strategy. Indeed, after some trial and error, was clear that, sometimes, the element
nis not ready yet even if the element
n+1was published as
maxitemand the API returns the simple string "null", if that is the case we simply repeat the call.
REDISQL.EXEC $db_name "CREATE TABLE ... etc"and, if you want, the statements:
REDISSQL.CREATE_STATEMENT $db_name $statement_name "INSERT INTO ... etc"
REDISQL.QUERY $db_name "SELECT * FROM ...",
REDISQL.CREATE_STATEMENT $db_name $query_name "SELECT * FROM ... WHERE foo = ?1"and the
REDISQL.QUERY_STATEMENTS $db_name $query_name "paramenters"
REDISQL.EXEC $db_name "SELECT * FROM ... etc"