- "INSERT INTO peerstoredata (peer_id, sub_system, value) VALUES (?,?,?);",
- &plugin->insert_peerstoredata);
- sql_prepare(plugin->dbh,
- "SELECT peer_id, sub_system, value FROM peerstoredata",
- &plugin->select_peerstoredata);
- sql_prepare(plugin->dbh,
- "SELECT peer_id, sub_system, value FROM peerstoredata WHERE peer_id = ?",
- &plugin->select_peerstoredata_by_pid);
- sql_prepare(plugin->dbh,
- "SELECT peer_id, sub_system, value FROM peerstoredata WHERE sub_system = ?",
- &plugin->select_peerstoredata_by_ss);
- sql_prepare(plugin->dbh,
- "SELECT peer_id, sub_system, value FROM peerstoredata WHERE peer_id = ? AND sub_system = ?",
- &plugin->select_peerstoredata_by_both);
-
+ "INSERT INTO peerstoredata (sub_system, peer_id, key, value, expiry)"
+ " VALUES (?,?,?,?,?);",
+ &plugin->insert_peerstoredata);
+ sql_prepare (plugin->dbh,
+ "SELECT sub_system,peer_id,key,value,expiry FROM peerstoredata"
+ " WHERE sub_system = ?",
+ &plugin->select_peerstoredata);
+ sql_prepare (plugin->dbh,
+ "SELECT sub_system,peer_id,key,value,expiry FROM peerstoredata"
+ " WHERE sub_system = ?"
+ " AND peer_id = ?",
+ &plugin->select_peerstoredata_by_pid);
+ sql_prepare (plugin->dbh,
+ "SELECT sub_system,peer_id,key,value,expiry FROM peerstoredata"
+ " WHERE sub_system = ?"
+ " AND key = ?",
+ &plugin->select_peerstoredata_by_key);
+ sql_prepare (plugin->dbh,
+ "SELECT sub_system,peer_id,key,value,expiry FROM peerstoredata"
+ " WHERE sub_system = ?"
+ " AND peer_id = ?" " AND key = ?",
+ &plugin->select_peerstoredata_by_all);
+ sql_prepare (plugin->dbh,
+ "DELETE FROM peerstoredata"
+ " WHERE expiry < ?",
+ &plugin->expire_peerstoredata);
+ sql_prepare (plugin->dbh,
+ "DELETE FROM peerstoredata"
+ " WHERE sub_system = ?"
+ " AND peer_id = ?" " AND key = ?",
+ &plugin->delete_peerstoredata);