Hikki::Adapters::MemcacheAdapter
A Memcache adapter for Hikki.
It uses the dalli
gem to communicate with Memcache.
Depending on expiry options and size of memory, all objects are not guaranteed to be available.
As such, index
, all
, and find_by
are not implemented.
The index
method will just return false
if called.
The all
and find_by
will return []
. Due to the repository logic, if this adapter is your first
adapter then calling all
on the repository will immediately try the next reader in the list.
Installation
Add this line to your application's Gemfile:
gem 'hikki-memcache'
And then execute:
$ bundle
Or install it yourself as:
$ gem install hikki-memcache
Usage
By default, the adapter will use Dalli::Client.new('localhost:11211', { namespace: 'hikki', compress: true })
as
it's connection.
You can pass in your own connection to use instead, useful for specifying a server, namespace and other options.
require 'memcache_adapter'
# Use the default connection
adapter = Hikki::Adapters::MemcacheAdapter.new
# Use a specific connection
cache = Dalli::Client.new('cache.example.com:11211', { namespace: 'my_cache' })
adapter = Hikki::Adapters::MemcacheAdapter.new(cache)
If you do not specify an id
when saving, the adapter will generate a uuid using SecureRandom
.
Contributing
- Fork it ( http://github.com/originate/hikki/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Write your specifications
- Implement your specifications
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request