semvec/pypi-packages huggingface dataset:
py-timed-cache 1.0.2
Pure Python timed-cache
License: MIT
Keywords: cache,timed-cache,timedcache

# timed-cache

Pure Python timed-cache that behaves like a regular `dict`.
Can also be used as a decorator to cache function calls (works for async functions as well).

## Installation

`pip install py-timed-cache`

## Example

```python
from timedcache import TimedCache

my_cache = TimedCache(1) # 1 second cache
my_cache["foo"] = "bar" # all dict methods works as if it was a normal dict
for k, v in my_cache.items():
    print(k, v) # will print foo bar

# Also works for functions

@TimedCache(5)
def foo(number):
    # some expensive compute...
    print("begin computation...")
    result = number * 10**30
    print("end computation")
    return res

big_number = foo(42) # cache MISS ==> this will print both statements above

big_number_again = foo(42) # Called with same argument(s) ==> cache HIT, returns immediately
```

## Python versions

Python >= 3.6 are supported

## Tests

This project uses `unittest`.

Run `python tests/test_timedcache.py`
flask-pg-session 0.1.0
Flask extension that implements server-side sessions in PostgreSQL
License: MIT
Requires Python: >3.8.1
Keywords: flask,server-side session,session

# FlaskPgSession

`FlaskPgSession` is a [`Flask`](https://flask.palletsprojects.com/) extensions that
implements server-side session support and stores the data in a PostgreSQL table.

It is inspired by [`Flask-Session`](https://flasksession.readthedocs.io/en/latest/)
but it's focused only on integration with PostgreSQL and therefore has fewer
dependencies.

It is intended for people that are already using Flask with PostgreSQL and do not want
to add another dependency to their app just for storing sessions (e.g. Redis).

## Installation

You can install `FlaskPgSession` using `pip`

```bash
pip install flask-pg-session
```

## Usage

Usage is pretty straightforward: just import `FlaskPgSession` and intialise it with
your `Flask` app:

```python
from flask import Flask
from flask_pg_session import FlaskPgSession

app = Flask("my-app")

# You can either pass the app as an argument to the constructor
FlaskPgSession(app)

# or initialise it separately
session = FlaskPgSession()
session.init_app(app)
```

## Configuration

The extension can be configured via the `Flask` config file. The following options are
available:

- `SQLALCHEMY_DATABASE_URI`: The URI of the PostgreSQL database to use.
- `SESSION_PG_TABLE`: The name of the table to store sessions in. Defaults to `flask_sessions`.
- `SESSION_PG_SCHEMA`: The name of the schema to store sessions in. Defaults to `public`.
- `SESSION_KEY_PREFIX`: The prefix to use for session IDs. Absent by default.
- `SESSION_USE_SIGNER`: Whether to sign session IDs. Defaults to False.
- `SESSION_PERMANENT`: Whether to set the `permanent` flag on sessions. Defaults to True.
- `SESSION_AUTODELETE_EXPIRED`: Whether to automatically delete expired
sessions. Defaults to True.
- `SESSION_PG_MAX_DB_CONN`: The maximum number of database connections to use. Defaults to 10.

## Contributions

Contributions are welcome! If you encounter any issues, have suggestions, or would like
to contribute to `FlaskPgSession`, please feel free to submit a pull request or
open an issue.


## License

`FlaskPgSession` is open source and released under the MIT License.