cache

package
v0.0.0-...-a70abb3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright © 2021 David Morgan <dmorgan81@gmail.com>

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 © 2021 David Morgan <dmorgan81@gmail.com>

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 © 2021 David Morgan <dmorgan81@gmail.com>

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 © 2021 David Morgan <dmorgan81@gmail.com>

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 ErrNotFound = errors.New("cache: not found")

Functions

func NewServer

func NewServer(addr string, cache Cache) *http.Server

Types

type Cache

type Cache interface {
	Exists(context.Context, Store, Key) error
	Reader(context.Context, Store, Key) (io.Reader, int64, error)
	Writer(context.Context, Store, Key) (io.Writer, error)
}

type Key

type Key string

func (Key) String

func (k Key) String() string

type LRU

type LRU struct {
	// contains filtered or unexported fields
}

func NewLRUCache

func NewLRUCache(cache Cache, max int64) *LRU

func (*LRU) Check

func (c *LRU) Check(ctx context.Context) error

func (*LRU) Exists

func (c *LRU) Exists(ctx context.Context, store Store, key Key) error

func (*LRU) Reader

func (c *LRU) Reader(ctx context.Context, store Store, key Key) (io.Reader, int64, error)

func (*LRU) Writer

func (c *LRU) Writer(ctx context.Context, store Store, key Key) (io.Writer, error)

type MemCache

type MemCache struct {
	// contains filtered or unexported fields
}

func NewMemCache

func NewMemCache() *MemCache

func (*MemCache) Exists

func (c *MemCache) Exists(_ context.Context, store Store, key Key) error

func (*MemCache) Reader

func (c *MemCache) Reader(_ context.Context, store Store, key Key) (io.Reader, int64, error)

func (*MemCache) Writer

func (c *MemCache) Writer(_ context.Context, store Store, key Key) (io.Writer, error)

type Store

type Store string
const (
	AC  Store = "ac"
	CAS Store = "cas"
)

func (Store) String

func (s Store) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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