Class: AtprotoAuth::Storage::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/atproto_auth/storage/interface.rb

Overview

Base storage interface that all implementations must conform to

Direct Known Subclasses

Memory, Redis

Instance Method Summary collapse

Instance Method Details

#acquire_lock(key, ttl:) ⇒ Boolean

Acquire a lock

Parameters:

  • key (String)

    Lock key

  • ttl (Integer)

    Lock timeout in seconds

Returns:

  • (Boolean)

    True if lock acquired

Raises:



63
64
65
# File 'lib/atproto_auth/storage/interface.rb', line 63

def acquire_lock(key, ttl:)
  raise NotImplementedError
end

#delete(key) ⇒ Boolean

Delete a value

Parameters:

  • key (String)

    Storage key

Returns:

  • (Boolean)

    Success status

Raises:



29
30
31
# File 'lib/atproto_auth/storage/interface.rb', line 29

def delete(key)
  raise NotImplementedError
end

#exists?(key) ⇒ Boolean

Check if key exists

Parameters:

  • key (String)

    Storage key

Returns:

  • (Boolean)

    True if key exists

Raises:



37
38
39
# File 'lib/atproto_auth/storage/interface.rb', line 37

def exists?(key)
  raise NotImplementedError
end

#get(key) ⇒ Object?

Retrieve a value

Parameters:

  • key (String)

    Storage key

Returns:

  • (Object, nil)

    Stored value or nil if not found

Raises:



21
22
23
# File 'lib/atproto_auth/storage/interface.rb', line 21

def get(key)
  raise NotImplementedError
end

#multi_get(keys) ⇒ Hash<String, Object>

Get multiple values

Parameters:

  • keys (Array<String>)

    Storage keys

Returns:

  • (Hash<String, Object>)

    Key-value pairs

Raises:



45
46
47
# File 'lib/atproto_auth/storage/interface.rb', line 45

def multi_get(keys)
  raise NotImplementedError
end

#multi_set(hash, ttl: nil) ⇒ Boolean

Store multiple values

Parameters:

  • hash (Hash<String, Object>)

    Key-value pairs

  • ttl (Integer, nil) (defaults to: nil)

    Time-to-live in seconds

Returns:

  • (Boolean)

    Success status

Raises:



54
55
56
# File 'lib/atproto_auth/storage/interface.rb', line 54

def multi_set(hash, ttl: nil)
  raise NotImplementedError
end

#release_lock(key) ⇒ Boolean

Release a lock

Parameters:

  • key (String)

    Lock key

Returns:

  • (Boolean)

    Success status

Raises:



71
72
73
# File 'lib/atproto_auth/storage/interface.rb', line 71

def release_lock(key)
  raise NotImplementedError
end

#set(key, value, ttl: nil) ⇒ Boolean

Store a value with optional TTL

Parameters:

  • key (String)

    Storage key

  • value (Object)

    Value to store

  • ttl (Integer, nil) (defaults to: nil)

    Time-to-live in seconds

Returns:

  • (Boolean)

    Success status

Raises:



13
14
15
# File 'lib/atproto_auth/storage/interface.rb', line 13

def set(key, value, ttl: nil)
  raise NotImplementedError
end

#with_lock(key, ttl: 30) { ... } ⇒ Object

Execute block with lock

Parameters:

  • key (String)

    Lock key

  • ttl (Integer) (defaults to: 30)

    Lock timeout in seconds

Yields:

  • Block to execute with lock

Returns:

  • (Object)

    Block result

Raises:



81
82
83
# File 'lib/atproto_auth/storage/interface.rb', line 81

def with_lock(key, ttl: 30)
  raise NotImplementedError
end