MasoniteFramework / masonite4

Temporary Repository for a Masonite Rewrite for Masonite 4
14 stars 3 forks source link

Add Caching #23

Closed josephmancuso closed 3 years ago

josephmancuso commented 3 years ago

Caching is one of those extremely primitive features of Masonite that are probably rarely used because of the simplicity of it.

Right now the cache just stores in the file and I don't even think its compatible with Windows because of how it names the files.

Also this is only doing 1 thing right now which is storing sessions as files. A real feature should be able to support things like caching in:

The configuration settings should be created more similiar to how we do database connections rather than queues. For example with the database you could have multiple "connection" that use the same driver. For example, you could have a staging and production connection that both use MySQL.

With the caching it should be the same where you have multiple "Stores" (taken from Laravel) and different stores could have the same driver that powers them.

The API should have the following methods.

class FileDriver:

def increment(self, key, amount=1): pass
def decrement(self, key, amount=1): pass
def remember(self, key, length, callable): pass
def get(self, key, default=None): pass
def put(self, key, default=None): pass
def has(self, key): pass
def forget(self, key): pass
def flush(self, key): pass

Should also support tags on some drivers. Can prob be done through a paramter:

application.make('cache').store('database').put('key', 'value', tags=["p1", "p2"])