pub struct FireflyStream {
pub default_ttl: usize,
/* private fields */
}Fields§
§default_ttl: usizeThe default TTL for new records. If this value is not zero, it will be added to the current timestamp. So this is the TTL from when the new is executed.
Implementations§
Source§impl FireflyStream
impl FireflyStream
Sourcepub async fn connect(address: &str) -> FireflyResult<Self>
pub async fn connect(address: &str) -> FireflyResult<Self>
Instantiate a new TCP connection with a Firefly server. Fails if the connection cannot be established. The expected buffer size is set to 512.
§Arguments
address- The address of the Firefly server. (e.g. “127.0.0.1:46600”)
Sourcepub async fn connect_with_max_buffer(
address: &str,
max_buffer_size: usize,
) -> FireflyResult<Self>
pub async fn connect_with_max_buffer( address: &str, max_buffer_size: usize, ) -> FireflyResult<Self>
Same as FireflyStream::connect, but with a custom buffer size.
The buffer size is the maximum expected response size.
§Arguments
address- The address of the Firefly server. (e.g. “127.0.0.1:46600”)max_buffer_size- The maximum expected response size.
Sourcepub async fn new(&self, key: &str, value: &str) -> OptResult
pub async fn new(&self, key: &str, value: &str) -> OptResult
Create a new record with the default TTL. The default TTL is 0. (record lasts for ever)
§Arguments
key- Your unique key for the record.value- The value of the record.
Sourcepub async fn new_with_ttl(
&self,
key: &str,
value: &str,
ttl: usize,
) -> OptResult
pub async fn new_with_ttl( &self, key: &str, value: &str, ttl: usize, ) -> OptResult
Same as FireflyStream::new, but with a custom TTL.
The TTL is the timestamp since the UNIX epoch.
§Arguments
key- Your unique key for the record.value- The value of the record.ttl- The timestamp since the UNIX epoch for the data to expire. (0 = never)
Sourcepub async fn get(&self, key: &str) -> FireflyResult<(String, usize)>
pub async fn get(&self, key: &str) -> FireflyResult<(String, usize)>
Get a record from the Firefly server. If you only need the value or ttl use the specific methods for those purposes. As this returns both values.
§Arguments
key- The key of the record.
Sourcepub async fn get_value(&self, key: &str) -> StringResult
pub async fn get_value(&self, key: &str) -> StringResult
Sourcepub async fn get_ttl(&self, key: &str) -> FireflyResult<usize>
pub async fn get_ttl(&self, key: &str) -> FireflyResult<usize>
Sourcepub async fn drop_values(&self, value: &str) -> OptResult
pub async fn drop_values(&self, value: &str) -> OptResult
Remove ALL records that have a certain value. Using this method is generally discouraged. As it is a heavy operation.
§Arguments
value- The valy of ANY record that should be removed.