cache/engine.h
author Tero Marttila <terom@fixme.fi>
Fri, 08 Aug 2008 00:15:29 +0300
changeset 31 12d5361e7472
parent 30 33e464fd6773
child 33 b750e8865127
permissions -rw-r--r--
req/write/push implemented
#ifndef CACHE_ENGINE_H
#define CACHE_ENGINE_H

struct cache_engine {
    /*
     * Allocate a `struct cache`-compatible struct and return it via cache_ptr.
     */
    int (*fn_init) (struct cache_engine *, struct cache **);
    
    /*
     * Allocate a `struct cache_op`-compatible struct and return it via cache_ptr.
     *
     * Begin the index lookup.
     */
    int (*fn_op_start) (struct cache *, struct cache_op **, struct cache_key *);

    /*
     * Prepare to write and possibly read this cache entry.
     *
     * size_hint, if nonzero, provides a guess at the size of the cache entry that can be used to optimize stuff
     */
    int (*fn_op_begin_write) (struct cache_op *, size_t size_hint);

    int (*fn_op_push) (struct cache_op *op, int fd, size_t *size);
};

#endif /* CACHE_ENGINE_H */