Skip to content

Commit

Permalink
Apply cfformat changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lmajano authored and github-actions[bot] committed Apr 19, 2023
1 parent b76dc00 commit 2da4b1c
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 60 deletions.
2 changes: 1 addition & 1 deletion models/AbstractStorage.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ component accessors="true" serializable="false" {
* call the `produce` closure/lambda to produce the required value and store it
* in the storage using the passed named key.
*
* @name The name of the key to get
* @name The name of the key to get
* @produce The closure/lambda to execute that should produce the value
*/
any function getOrSet( required name, required any produce ){
Expand Down
4 changes: 2 additions & 2 deletions models/ApplicationStorage.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ component
/**
* Set a new variable in storage
*
* @name The name of the data key
* @name The name of the data key
* @value The value of the data to store
*
* @return cbstorages.models.IStorage
Expand All @@ -44,7 +44,7 @@ component
/**
* Get a new variable in storage if it exists, else return default value, else will return null.
*
* @name The name of the data key
* @name The name of the data key
* @defaultValue The default value to return if not found in storage
*/
any function get( required name, defaultValue ){
Expand Down
4 changes: 2 additions & 2 deletions models/CGIStorage.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ component
/**
* Set a new variable in storage
*
* @name The name of the data key
* @name The name of the data key
* @value The value of the data to store
*
* @return cbstorages.models.IStorage
Expand All @@ -41,7 +41,7 @@ component
/**
* Get a new variable in storage if it exists, else return default value, else will return null.
*
* @name The name of the data key
* @name The name of the data key
* @defaultValue The default value to return if not found in storage
*/
any function get( required name, defaultValue ){
Expand Down
34 changes: 8 additions & 26 deletions models/CacheStorage.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ component
/**
* Constructor
*
* @settings The storage settings struct
* @cachebox A reference to CacheBox
* @settings The storage settings struct
* @cachebox A reference to CacheBox
* @settings.inject coldbox:moduleSettings:cbstorages
* @cachebox.inject cachebox
*/
Expand All @@ -65,7 +65,7 @@ component
/**
* Set a new variable in storage
*
* @name The name of the data key
* @name The name of the data key
* @value The value of the data to store
*
* @return cbstorages.models.IStorage
Expand All @@ -75,20 +75,15 @@ component
// store in bucket
storage[ arguments.name ] = arguments.value;
// save it back in cache
cache.set(
getSessionKey(),
storage,
variables.timeout,
0
);
cache.set( getSessionKey(), storage, variables.timeout, 0 );

return this;
}

/**
* Get a new variable in storage if it exists, else return default value, else will return null.
*
* @name The name of the data key
* @name The name of the data key
* @defaultValue The default value to return if not found in storage
*/
any function get( required name, defaultValue ){
Expand All @@ -114,12 +109,7 @@ component
if ( structKeyExists( storage, arguments.name ) ) {
structDelete( storage, arguments.name );
// store it back
cache.set(
getSessionKey(),
storage,
variables.timeout,
0
);
cache.set( getSessionKey(), storage, variables.timeout, 0 );
return true;
}
return false;
Expand All @@ -144,16 +134,8 @@ component
var storage = cache.get( cacheKey );
// Verify, else create it
if ( isNull( local.storage ) ) {
storage = {
"sessionid" : cacheKey,
"timecreated" : now()
};
cache.set(
cacheKey,
storage,
variables.timeout,
0
);
storage = { "sessionid" : cacheKey, "timecreated" : now() };
cache.set( cacheKey, storage, variables.timeout, 0 );
}

return storage;
Expand Down
4 changes: 2 additions & 2 deletions models/ClientStorage.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ component
/**
* Set a new variable in storage
*
* @name The name of the data key
* @name The name of the data key
* @value The value of the data to store
*
* @return cbstorages.models.IStorage
Expand All @@ -40,7 +40,7 @@ component
/**
* Get a new variable in storage if it exists, else return default value, else will return null.
*
* @name The name of the data key
* @name The name of the data key
* @defaultValue The default value to return if not found in storage
*/
any function get( required name, defaultValue ){
Expand Down
21 changes: 10 additions & 11 deletions models/CookieStorage.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ component
/**
* Constructor
*
* @settings The storage settings struct
* @settings The storage settings struct
* @settings.inject coldbox:moduleSettings:cbStorages
*/
function init( required settings ){
Expand All @@ -84,12 +84,12 @@ component
/**
* Set a new variable in storage
*
* @name The name of the data key
* @value The value of the data to store
* @expires Cookie expiration
* @secure If browser does not support Secure Sockets Layer (SSL) security, the cookie is not sent. To use the cookie, the page must be accessed using the https protocol.
* @path URL, within a domain, to which the cookie applies; typically a directory. Only pages in this path can use the cookie. By default, all pages on the server that set the cookie can access the cookie.
* @domain Domain in which cookie is valid and to which cookie content can be sent from the user's system.
* @name The name of the data key
* @value The value of the data to store
* @expires Cookie expiration
* @secure If browser does not support Secure Sockets Layer (SSL) security, the cookie is not sent. To use the cookie, the page must be accessed using the https protocol.
* @path URL, within a domain, to which the cookie applies; typically a directory. Only pages in this path can use the cookie. By default, all pages on the server that set the cookie can access the cookie.
* @domain Domain in which cookie is valid and to which cookie content can be sent from the user's system.
* @httpOnly Apply the httpOnly or use the storage default
* @sameSite Tells browsers when and how to fire cookies in first-or third-party situations. SameSite is used to identify whether or not to allow a cookie to be accessed. Defaults not set. Available options are strict, lax, or none
*
Expand Down Expand Up @@ -154,7 +154,7 @@ component
/**
* Get a new variable in storage if it exists, else return default value, else will return null.
*
* @name The name of the data key
* @name The name of the data key
* @defaultValue The default value to return if not found in storage
*/
any function get( required name, defaultValue ){
Expand Down Expand Up @@ -190,10 +190,9 @@ component
/**
* Delete a variable in the storage
*
* @name The name of the data key
* @path URL, within a domain, to which the cookie applies; typically a directory. Only pages in this path can use the cookie. By default, all pages on the server that set the cookie can access the cookie.
* @name The name of the data key
* @path URL, within a domain, to which the cookie applies; typically a directory. Only pages in this path can use the cookie. By default, all pages on the server that set the cookie can access the cookie.
* @domain Domain in which cookie is valid and to which cookie content can be sent from the user's system.
*
*/
boolean function delete(
required name,
Expand Down
7 changes: 3 additions & 4 deletions models/IStorage.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface {
/**
* Set a new variable in storage
*
* @name The name of the data key
* @name The name of the data key
* @value The value of the data to store
*
* @return cbstorages.models.IStorage
Expand All @@ -28,7 +28,7 @@ interface {
/**
* Get a new variable in storage if it exists, else return default value, else will return null.
*
* @name The name of the data key
* @name The name of the data key
* @defaultValue The default value to return if not found in storage
*/
any function get( required name, defaultValue );
Expand All @@ -38,7 +38,7 @@ interface {
* call the `produce` closure/lambda to produce the required value and store it
* in the storage using the passed named key.
*
* @name The name of the key to get
* @name The name of the key to get
* @produce The closure/lambda to execute that should produce the value
*/
any function getOrSet( required name, required any produce );
Expand Down Expand Up @@ -117,7 +117,6 @@ interface {
/**
* Create the storage
*
*
* @return cbstorages.models.IStorage
*/
any function createStorage();
Expand Down
4 changes: 2 additions & 2 deletions models/RequestStorage.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ component
/**
* Set a new variable in storage
*
* @name The name of the data key
* @name The name of the data key
* @value The value of the data to store
*
* @return cbstorages.models.IStorage
Expand All @@ -43,7 +43,7 @@ component
/**
* Get a new variable in storage if it exists, else return default value, else will return null.
*
* @name The name of the data key
* @name The name of the data key
* @defaultValue The default value to return if not found in storage
*/
any function get( required name, defaultValue ){
Expand Down
4 changes: 2 additions & 2 deletions models/SessionStorage.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ component
/**
* Set a new variable in storage
*
* @name The name of the data key
* @name The name of the data key
* @value The value of the data to store
*
* @return cbstorages.models.IStorage
Expand All @@ -41,7 +41,7 @@ component
/**
* Get a new variable in storage if it exists, else return default value, else will return null.
*
* @name The name of the data key
* @name The name of the data key
* @defaultValue The default value to return if not found in storage
*/
any function get( required name, defaultValue ){
Expand Down
9 changes: 1 addition & 8 deletions test-harness/tests/specs/CookieStorageTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,7 @@ component extends="coldbox.system.testing.BaseTestCase" appMapping="/root" {
expect( storage.get( "tester-encrypt" ) ).toBe( 1 );

/* Set Complex */
storage.set(
"tester-encrypt",
{
"name" : "luis",
"now" : now(),
"kids" : [ 1, 2, 3 ]
}
);
storage.set( "tester-encrypt", { "name" : "luis", "now" : now(), "kids" : [ 1, 2, 3 ] } );
expect( storage.exists( "tester-encrypt" ) ).toBeTrue();
expect( storage.get( "tester-encrypt" ) ).toBeStruct();
} );
Expand Down

0 comments on commit 2da4b1c

Please sign in to comment.