MCPcopy Create free account
hub / github.com/adonisjs/session / constructor

Method constructor

src/stores/database.ts:67–98  ·  view source on GitHub ↗

* Creates a new database store instance * * @param client - Lucid query client instance * @param age - Session age in seconds or time expression (e.g. '2 hours') * @param options - Configuration options * @param options.tableName - Database table name (defaults to "sessions") * @pa

(
    client: QueryClientContract,
    age: string | number,
    options?: {
      /**
       * Defaults to "sessions"
       */
      tableName?: string

      /**
       * The probability (in percent) that garbage collection will be
       * triggered on any given request. For example, 2 means 2% chance.
       *
       * Set to 0 to disable garbage collection.
       *
       * Defaults to 2 (2% chance)
       */
      gcProbability?: number

      /**
       * Encrypts the session data instead of only signing it
       */
      encryption?: SessionEncryption
    }
  )

Source from the content-addressed store, hash-verified

65 * @param options.gcProbability - Garbage collection probability in percent (defaults to 2)
66 */
67 constructor(
68 client: QueryClientContract,
69 age: string | number,
70 options?: {
71 /**
72 * Defaults to "sessions"
73 */
74 tableName?: string
75
76 /**
77 * The probability (in percent) that garbage collection will be
78 * triggered on any given request. For example, 2 means 2% chance.
79 *
80 * Set to 0 to disable garbage collection.
81 *
82 * Defaults to 2 (2% chance)
83 */
84 gcProbability?: number
85
86 /**
87 * Encrypts the session data instead of only signing it
88 */
89 encryption?: SessionEncryption
90 }
91 ) {
92 this.#client = client
93 this.#tableName = options?.tableName ?? 'sessions'
94 this.#ttlSeconds = string.seconds.parse(age)
95 this.#gcProbability = options?.gcProbability ?? 2
96 this.#encryption = options?.encryption
97 debug('initiating database store')
98 }
99
100 /**
101 * Runs garbage collection to delete expired sessions from the database.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected