Node-famcache is a Node.js client for Famcache, a caching server written in Go. This client allows you to interact with the Famcache server from your Node.js applications, providing an easy-to-use interface for caching operations.
To install Node-famcache, use npm:
npm install @famcache/famcache
First, import the module and create a client instance:
import Famcache from '@famcache/famcache';
const client = new FamcacheClient({
host: 'localhost',
port: 3577,
});
To store a value in the cache:
await client.set('key', 'value', 30000);
To retrieve a value from the cache:
const value = await client.get('key');
To delete a value from the cache:
await client.del('key');
To publish data to the topic:
client.messaging.publish('topic', 'data');
To subscribe to the topic:
client.messaging.subscribe('topic', (data) => {
// ...
});
To unsubscribe from the topic:
client.messaging.unsubscribe('topic');
FamcacheClientnew FamcacheClient(options)Creates a new client instance.
client.set(key, value, ttl?)Sets a value in the cache.
client.get(key)Gets a value from the cache.
client.delete(key, callback)Deletes a value from the cache.
client.messaging.publish(topic, data)Publishes data to the topic
client.messaging.subscribe(topic, callback)Subscribes to the topic
client.messaging.unsubscribe(topic)Unsubscribes from the topic
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Node-famcache is licensed under the MIT License. See the LICENSE file for more details.