cachestore

package
v0.0.0-...-800783e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

README

cachestore

beta 1

Documentation

Overview

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	// the collection name of redis for cache adapter.
	DefaultKey string = "WebxRedis"
)

Functions

func Decode

func Decode(data []byte, to interface{}) error

func Encode

func Encode(data interface{}) ([]byte, error)

func Md5

func Md5(v string) string

Types

type Bolt

type Bolt struct {
	Debug bool
	// contains filtered or unexported fields
}

Bolt implements ds.Datastore TODO: use buckets to represent the heirarchy of the ds.Keys

func NewBolt

func NewBolt(dbFile, bucket string) (*Bolt, error)

func (*Bolt) Close

func (bd *Bolt) Close() error

func (*Bolt) ConsumeValue

func (bd *Bolt) ConsumeValue(key string, f func([]byte) error) error

func (*Bolt) Del

func (bd *Bolt) Del(key string) error

func (*Bolt) Get

func (bd *Bolt) Get(key string) (interface{}, error)

func (*Bolt) Has

func (bd *Bolt) Has(key string) (bool, error)

func (*Bolt) Put

func (bd *Bolt) Put(key string, val interface{}) error

func (*Bolt) PutMany

func (bd *Bolt) PutMany(data map[string]interface{}) error

type Closer

type Closer interface {
	Close() error
}

type LevelDB

type LevelDB struct {
	Debug bool
	// contains filtered or unexported fields
}

LevelDB implements CacheStore provide local machine

func NewLevelDB

func NewLevelDB(dbfile string) *LevelDB

func (*LevelDB) Close

func (s *LevelDB) Close() error

func (*LevelDB) Del

func (s *LevelDB) Del(key string) error

func (*LevelDB) Get

func (s *LevelDB) Get(key string) (interface{}, error)

func (*LevelDB) Put

func (s *LevelDB) Put(key string, value interface{}) error

type Memcache

type Memcache struct {
	LifeTime int32
	Debug    bool
	// contains filtered or unexported fields
}

Memcache adapter.

func NewMemcache

func NewMemcache(conn []string, lifeTime int32) *Memcache

create new memcache adapter.

func (*Memcache) ClearAll

func (rc *Memcache) ClearAll() error

clear all cached in memcache.

func (*Memcache) Decr

func (rc *Memcache) Decr(key string, delta uint64) error

[Not Support] decrease counter.

func (*Memcache) Del

func (rc *Memcache) Del(key string) error

delete value in memcache.

func (*Memcache) Get

func (rc *Memcache) Get(key string) (interface{}, error)

get value from memcache.

func (*Memcache) Incr

func (rc *Memcache) Incr(key string, delta uint64) error

[Not Support] increase counter.

func (*Memcache) IsExist

func (rc *Memcache) IsExist(key string) bool

check value exists in memcache.

func (*Memcache) Put

func (rc *Memcache) Put(key string, value interface{}) error

put value to memcache. only support string.

type Redis

type Redis struct {
	Debug    bool
	LifeTime int32
	// contains filtered or unexported fields
}

Redis cache adapter.

func NewRedis

func NewRedis(cf map[string]string, lifeTime int32) *Redis

create new redis cache with default collection name.

func (*Redis) ClearAll

func (rc *Redis) ClearAll() error

clean all cache in redis. delete this redis collection.

func (*Redis) Connect

func (rc *Redis) Connect(config string) error

start redis cache adapter. config is like {"key":"collection key","conn":"connection info","dbnum":"0"} the cache item in redis are stored forever, so no gc operation.

func (*Redis) Decr

func (rc *Redis) Decr(key string, delta uint64) error

decrease counter in redis.

func (*Redis) Del

func (rc *Redis) Del(key string) error

delete cache in redis.

func (*Redis) Get

func (rc *Redis) Get(key string) (interface{}, error)

Get cache from redis.

func (*Redis) Incr

func (rc *Redis) Incr(key string, delta uint64) error

increase counter in redis.

func (*Redis) IsExist

func (rc *Redis) IsExist(key string) bool

check cache exist in redis.

func (*Redis) Put

func (rc *Redis) Put(key string, value interface{}) error

put cache to redis. timeout is ignored.

Directories

Path Synopsis
redigo
redis
Package redis is a client for the Redis database.
Package redis is a client for the Redis database.
redisx
Package redisx contains experimental features for Redigo.
Package redisx contains experimental features for Redigo.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL