2121 * related information.
2222 * @param {string } prefix The prefix to use for keys in the properties and
2323 * cache.
24- * @param {PropertiesService.Properties } properties The properties instance to
25- * use.
24+ * @param {PropertiesService.Properties } optProperties The optional properties
25+ * instance to use.
2626 * @param {CacheService.Cache } [optCache] The optional cache instance to use.
2727 * @constructor
2828 */
29- function Storage_ ( prefix , properties , optCache ) {
29+ function Storage_ ( prefix , optProperties , optCache ) {
3030 this . prefix_ = prefix ;
31- this . properties_ = properties ;
31+ this . properties_ = optProperties ;
3232 this . cache_ = optCache ;
3333 this . memory_ = { } ;
3434}
@@ -80,7 +80,8 @@ Storage_.prototype.getValue = function(key, optSkipMemoryCheck) {
8080 }
8181
8282 // Check properties.
83- if ( jsonValue = this . properties_ . getProperty ( prefixedKey ) ) {
83+ if ( this . properties_ &&
84+ ( jsonValue = this . properties_ . getProperty ( prefixedKey ) ) ) {
8485 if ( this . cache_ ) {
8586 this . cache_ . put ( prefixedKey ,
8687 jsonValue , Storage_ . CACHE_EXPIRATION_TIME_SECONDS ) ;
@@ -108,7 +109,9 @@ Storage_.prototype.getValue = function(key, optSkipMemoryCheck) {
108109Storage_ . prototype . setValue = function ( key , value ) {
109110 var prefixedKey = this . getPrefixedKey_ ( key ) ;
110111 var jsonValue = JSON . stringify ( value ) ;
111- this . properties_ . setProperty ( prefixedKey , jsonValue ) ;
112+ if ( this . properties_ ) {
113+ this . properties_ . setProperty ( prefixedKey , jsonValue ) ;
114+ }
112115 if ( this . cache_ ) {
113116 this . cache_ . put ( prefixedKey , jsonValue ,
114117 Storage_ . CACHE_EXPIRATION_TIME_SECONDS ) ;
@@ -122,7 +125,9 @@ Storage_.prototype.setValue = function(key, value) {
122125 */
123126Storage_ . prototype . removeValue = function ( key ) {
124127 var prefixedKey = this . getPrefixedKey_ ( key ) ;
125- this . properties_ . deleteProperty ( prefixedKey ) ;
128+ if ( this . properties_ ) {
129+ this . properties_ . deleteProperty ( prefixedKey ) ;
130+ }
126131 if ( this . cache_ ) {
127132 this . cache_ . remove ( prefixedKey ) ;
128133 }
0 commit comments