storage.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package extension
  2. import (
  3. "context"
  4. "github.com/v2fly/v2ray-core/v4/features"
  5. )
  6. type PersistentStorageEngine interface {
  7. features.Feature
  8. PersistentStorageEngine()
  9. Put(ctx context.Context, key []byte, value []byte) error
  10. Get(ctx context.Context, key []byte) ([]byte, error)
  11. List(ctx context.Context, keyPrefix []byte) ([][]byte, error)
  12. }
  13. type ScopedPersistentStorage interface {
  14. ScopedPersistentStorageEngine()
  15. Put(ctx context.Context, key []byte, value []byte) error
  16. Get(ctx context.Context, key []byte) ([]byte, error)
  17. List(ctx context.Context, keyPrefix []byte) ([][]byte, error)
  18. ClearIfCharacteristicMismatch(ctx context.Context, characteristic []byte) error
  19. NarrowScope(ctx context.Context, key []byte) (ScopedPersistentStorage, error)
  20. }
  21. type ScopedTransientStorage interface {
  22. ScopedTransientStorage()
  23. Put(ctx context.Context, key []byte, value interface{}) error
  24. Get(ctx context.Context, key []byte) (interface{}, error)
  25. List(ctx context.Context, keyPrefix []byte) ([][]byte, error)
  26. Clear(ctx context.Context)
  27. NarrowScope(ctx context.Context, key []byte) (ScopedPersistentStorage, error)
  28. }