datastore: Index | Examples | Files

package rediscache

import ""

Package rediscache handles Put, Get etc to Datastore and provides caching by Redis. How the cache is used is explained in the storagecache package's document.

Related document.


package main

import (


const redisAddress = ":6379"

func main() {
    ctx := context.Background()
    client, err := clouddatastore.FromContext(ctx)
    if err != nil {
    defer client.Close()
    defer testutils.CleanUpAllEntities(ctx, client)

    dial, err := net.Dial("tcp", redisAddress)
    if err != nil {
    defer dial.Close()
    conn := redis.NewConn(dial, 100*time.Millisecond, 100*time.Millisecond)
    defer conn.Close()

    mw := rediscache.New(conn)



Package Files

doc.go option.go rediscache.go

func New Uses

func New(conn redis.Conn, opts ...CacheOption) interface {

New Redis cache middleware creates & returns.

type CacheOption Uses

type CacheOption interface {

A CacheOption is an cache option for a Redis cache middleware.

func WithCacheKey Uses

func WithCacheKey(f func(key datastore.Key) string) CacheOption

WithCacheKey creates a ClientOption that specifies how to generate a cache key from datastore.Key.

func WithExcludeKinds Uses

func WithExcludeKinds(kinds ...string) CacheOption

WithExcludeKinds creates a ClientOption that selects the Kind unspecified as the cache target.

func WithExpireDuration Uses

func WithExpireDuration(d time.Duration) CacheOption

WithExpireDuration creates a ClientOption to expire at a specified time.

func WithIncludeKinds Uses

func WithIncludeKinds(kinds ...string) CacheOption

WithIncludeKinds creates a ClientOption that selects the Kind specified as the cache target.

func WithKeyFilter Uses

func WithKeyFilter(f storagecache.KeyFilter) CacheOption

WithKeyFilter creates a ClientOption that selects the Keys specified as the cache target.

func WithLogger Uses

func WithLogger(logf func(ctx context.Context, format string, args ...interface{})) CacheOption

WithLogger creates a ClientOption that uses the specified logger.

Package rediscache imports 8 packages (graph). Updated 2018-06-23. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).