Boogaloo Simple Cache Server
Boogaloo is a very simple cache server that provides permanent and temporary object persistence, with the ability for objects to “expire”. Boogaloo can also be used for housing custom services, such as a registry or specialized cache implementation.
Boogaloo was initially developed for a RubyOnRails application that needed basic persistant object caching across multiple web nodes and a mechanism for caching objects related to a user temporarily rather than storing them in the session.
Getting Started
Caches are created in Boogaloo by specifying them in the configuration file. For example, to host one persistent and one temporary cache, your config may look something like this:
Server:
host: localhost
port: 7777
worker_threads: 3
PersistentCaches:
MyPersistentCache:
instance_name: main_cache
TemporaryCaches:
MyTempCache:
instance_name: temp_cache
check_frequency: 10
-
instance_name
is the method via which the cache instance will be accessed by the client. -
check_frequency
is the frequency in seconds at which the cache will check for stale objects to delete.
An example configuration file can be found in examples/boogalooo.conf.
Next start the Boogaloo server:
boogaloo -d -f boogaloo.conf
Now on the client we access the caches like this:
boogaloo_cache = Boogaloo::Client::Connection.new('localhost', 7777, true)
boogaloo_cache.main_cache.set(nil, "some_string", "Hello, World!")
boogaloo_cache.temp_cache.set(nil, "some_string", "Hello, World!", 20)
“Hello, World!” will persist for the lifetime of the server in main_cache, yet will be deleted in 20 seconds unless touched in temp_cache. By “unless touched” we mean that if the object is fetched from the cache with get() 10 seconds after being added, it’s expiration time will be reset to 20 seconds from the time it was fetched.
The boolean value passed into Connection tells the connection to return nil for all requests if the cache server is offline rather than throwing an exception.
Command Line Options
--config -c
-
The configuration file to use.
--daemon -d
-
Run as a stand-alone process.
Custom Services
You can also use Boogaloo to house your own custom services. These services can perform any task you want them to, all Boogaloo cares about is that you provide it with an interface to use.
Let say we create a new service called MyService and put it in a folder called /home/me/BoogalooServices/MyService, the only required file is an interface.rb
module MyService
class Interface
def initialize(arg1, arg2)
self.arg1 = arg1
self.arg2 = arg2
end
def arg1
self.arg1
end
def arg2
self.arg2
end
end
end
And then in our configuration file we put something like:
Services:
MyService:
instance_name: my_service
path: /home/me/BoogalooServices/MyService
arguments:
- Hello
- World
Restart Boogaloo and you’ll your service will be available as my_service on the client.
Boogaloo requires that your Interface class is contained within a module with the same name as specified in the configuration, in this case its MyService.
Boogaloo can also manage your $LOAD_PATH for you, see the detailed configuration documentation for more information.