I'm integrating memcached on a website that I'm developing and I'm wondering if anyone has a solution to my question. Ideally what I would like is a way to associate two keys with a stored value. That way I could use a specific query as the first key for retrieving the data during subsequent queries, and a more general key, i.e. the database table and primary key ([db-table-primary-key]), in order to easily delete any stored information associated with that row whenever that database row is updated. So the first key would be unique, but the second key could be shared amongst any data result sets associated with the same database row(s).
So, for example, I use the following as first memcached keys:
SELECT some_column_1 FROM some_table WHERE db_key = $key;
SELECT some_column_2 FROM some_table WHERE db_key = $key;
And the second memcached key would simply be the computed value of: "some_table-$key"
Then, if I update a row with the db_key = $key, I could simply delete any stored data associated with the second memcached key:
UPDATE some_table SET some_column_3 = '$value' WHERE db_key = $key;
$memcached->delete("some_table-$key");
As I said, that would be ideal, but I know that you cannot associate two keys with a stored memcached value, so is there another way to accomplish essentially the same thing?
Hopefully this is clear enough!