tequila
memory-store
 Constructor
19934
function (args) {
  if (false === (this instanceof MemoryStore)) throw new Error('new operator required');
  args = args || {};
  this.storeType = args.storeType || "MemoryStore";
  this.name = args.name || 'a ' + this.storeType;
  this.storeProperty = {
    isReady: true,
    canGetModel: true,
    canPutModel: true,
    canDeleteModel: true,
    canGetList: true
  };
  this.data = [];// Each ele is an array of model types and contents (which is an array of IDs and Model Value Store)
  this.idCounter = 0;
  var unusedProperties = getInvalidProperties(args, ['name', 'storeType']);
  var errorList = [];
  for (var i = 0; i < unusedProperties.length; i++) errorList.push('invalid property: ' + unusedProperties[i]);
  if (errorList.length > 1) throw new Error('error creating Store: multiple errors');
  if (errorList.length) throw new Error('error creating Store: ' + errorList[0]);
}
341144
function CacheStore(options) {
    if (!options.id) {
        throw new IdNotDefinedError();
    }
    var storeType, _cache;

    function parseKey(key) {
        return key.replace(/[^a-z0-9]/gi, '_').replace(/^-+/, '').replace(/-+$/, '').toLowerCase();
    }

    /**
     * Returns Cache Store object
     * @returns {Object}
     */
    this.getCacheStore = function () {
        return _cache;
    };

    /**
     * Method initiates cache store depends on type
     * @param type {String} cache store type
     * @returns {CacheStore}
     */
    this._setStoreType = function (type) {
        storeType = type;
        var ttl = options.expires || DEFAULT_EXPIRATION_TIME;
        options.max = options.max || 0; //makes lru cache to store infinite no of items
        switch (type) {
            case STORE_TYPE_MEMORY:
                _cache = CacheManager.caching({store: STORE_TYPE_MEMORY, max: options.max, ttl: ttl});
                break;

            case STORE_TYPE_REDIS:
                _cache = CacheManager.caching({store: RedisStore, db: options.db, ttl: ttl, host: options.host,
                    port: options.port, id: options.id
                });
                break;

            default :
                throw new InvalidCacheStoreTypeError(type);

        }
        //exposing delete method alias of _del
        _cache.delete = _cache.del;
        return this;
    };

    //setting public functions
    /**
     * Gets cache item
     * @param key {String} Key to retrieve cache item
     * @param next {Function} callback. parameters are err, value
     */
    this.get = function (key, next) {
        _cache.get(parseKey(key), next);
    };

    /**
     * Sets cache item in cache.
     * @param key {String} Key to retrieve cache item
     * @param value {String} Value to save cache item
     * @param next {Function} callback. parameters are err
     */
    this.set = function (key, value, next) {
        _cache.set(parseKey(key), value, next);
    };

    /**
     * Delete from cache
     * @param key {String} Key to retrieve cache item
     * @param next {Function} callback. parameters are err
     */
    this.delete = function (key, next) {
        _cache.del(parseKey(key), next);
    };

    /**
     * Wraps a function in cache, the first time the function is run,
     * its results are stored in cache so subsequent calls retrieve from cache
     * instead of calling the function.
     *
     * @example
     *
     *      var key = 'user_' + user_id;
     *      cache.wrap(key, function(cb) {
     *          User.get(user_id, cb);
     *      }, function(err, user) {
     *         console.log(user);
     *      });
     *
     * @param key {String} Key to retrieve cache item
     * @param wrapFn
     * @param next {Function} callback. parameters are err, value
     */
    this.wrap = function (key, wrapFn, next) {
        _cache.wrap(parseKey(key), wrapFn, next);
    };

    /**
     * Flushes the current cache store
     * @param next {Function} callback. parameters are err, success
     */
    this.reset = function (next) {
        _cache.reset(next);
    };

    /**
     * Gets all keys associated with this cache store
     * @param next {Function} callback. parameters are err, keys
     */
    this.keys = function (next) {
        _cache.keys(next);
    };
}
751874
private function constructCollector()
    {
        try {
            $this->collector = app()->make('lada.collector');
            $this->collector->startMeasuring();
        }
        catch (ReflectionException $e) {
            $this->collector = null;
        }
    }
219946
function initializeStore(config) {
		self.store = new Store(config.master, config);
		self.store.on('message', handleIncomingMessage);
		log.out('Store initialized.');
	}
1293658
function App() {
  return (
    <Store
      actions={{
        loadQuote,
        prevQuote,
        nextQuote,
        toggleColor
      }}
      initializers={{
        quotes: "loadQuote",
        numQuotes: "loadQuote"
      }}
      initialState={{
        quoteId: 1,
        color: "blue"
      }}
      derivedState={{
        quoteLengths: (getState, quoteId) => {
          return getState("quotes", quoteId).description.length
        }
      }}
      middleware={[consoleLogger]}
    >
      <ErrorBoundary fallback={ErrorMessage}>
        <Suspense fallback={<p>Loading...</p>}>
          <CurrentQuote />
        </Suspense>
      </ErrorBoundary>
    </Store>
  )
}
781227
public function storage_init()
    {
        // already initialized
        if (is_object($this->storage)) {
            return;
        }

        $driver       = $this->config->get('storage_driver', 'imap');
        $driver_class = "rcube_{$driver}";

        if (!class_exists($driver_class)) {
            self::raise_error(array(
                'code' => 700, 'type' => 'php',
                'file' => __FILE__, 'line' => __LINE__,
                'message' => "Storage driver class ($driver) not found!"),
                true, true);
        }

        // 
        $this->storage = new $driver_class;

        // for backward compat. (deprecated, will be removed)
        $this->imap = $this->storage;

        // set class options
        $options = array(
            'auth_type'      => $this->config->get("{$driver}_auth_type", 'check'),
            'auth_cid'       => $this->config->get("{$driver}_auth_cid"),
            'auth_pw'        => $this->config->get("{$driver}_auth_pw"),
            'debug'          => (bool) $this->config->get("{$driver}_debug"),
            'force_caps'     => (bool) $this->config->get("{$driver}_force_caps"),
            'disabled_caps'  => $this->config->get("{$driver}_disabled_caps"),
            'socket_options' => $this->config->get("{$driver}_conn_options"),
            'timeout'        => (int) $this->config->get("{$driver}_timeout"),
            'skip_deleted'   => (bool) $this->config->get('skip_deleted'),
            'driver'         => $driver,
        );

        if (!empty($_SESSION['storage_host'])) {
            $options['language'] = $_SESSION['language'];
            $options['host']     = $_SESSION['storage_host'];
            $options['user']     = $_SESSION['username'];
            $options['port']     = $_SESSION['storage_port'];
            $options['ssl']      = $_SESSION['storage_ssl'];
            $options['password'] = $this->decrypt($_SESSION['password']);
            $_SESSION[$driver.'_host'] = $_SESSION['storage_host'];
        }

        $options = $this->plugins->exec_hook("storage_init", $options);

        // for backward compat. (deprecated, to be removed)
        $options = $this->plugins->exec_hook("imap_init", $options);

        $this->storage->set_options($options);
        $this->set_storage_prop();

        // subscribe to 'storage_connected' hook for session logging
        if ($this->config->get('imap_log_session', false)) {
            $this->plugins->register_hook('storage_connected', array($this, 'storage_log_session'));
        }
    }
257630
function(callback) {
                var _this = this

                var initStorage = function() {
                    var obj = JSON.stringify([])
                    var _set = {}
                    _set[_this.key] = obj
                    storage.set(_set)

                    obj = JSON.parse(obj)

                    return obj
                }

                storage.get(this.key, function(items) {
                    var obj
                    if (Object.keys(items).length > 0) {
                        for (itemKey in items) {
                            obj = items[itemKey]
                            if (obj) {
                                obj = JSON.parse(obj)
                            }

                            if (obj === null || typeof obj === 'undefined') {
                                obj = initStorage()
                            } 
                            
                            if (callback) {
                                callback(obj)
                            }
                        }
                    } else {
                        obj = initStorage()
                        callback(obj)
                    }
                })
            }
1151154
function __() {
    var us = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
    var store = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

    store = typeof us === "boolean" ? us : store;
    us = typeof us === "boolean" ? [] : us;

    var seq = []; //seq is vanilla JS array + features
    seq.id = getID();
    seq.store = store;
    seq.us = us;
    seq.ds = [];
    seq.updatedTo = {};
    seq.us.map(function (u) {
      //  seq is a member of u.ds
      u.ds[u.ds.length] = seq;
      u.updatedTo[seq.id] = 0; // non-interference dependency
    });
    seq.IndexOnTimestamp = {};
    seq.TimestampOnIndex = {};
    seq.propagating = 0;
    seq.done = 0;
    seq.eqs = [];
    seq.addEq = function (eq) {
      return seq.eqs[seq.eqs.length] = eq;
    };
    seq.evalEqs = function (val) {
      var val0 = val;
      seq.eqs.map(function (eq) {
        return val = eq(val);
      });
      return seq.us.length === 0 ? val0 : val;
    };
    //api-----------------
    Object.keys(__.api).map(function (api) {
      seq[api] = __.api[api](__, seq, store);
    });
    //-----------------
    Object.defineProperties(seq, //detect t update on each seqs
    {
      t: {
        //foo.t
        get: function get() {
          return seq.valOnT;
        },
        set: function set(tval) {
          var sanityCheck = seq.propagating === 0 && seq.us.length !== 0 ? function () {
            throw new Error("Do not set a value of the sequence that depends on other sequences!");
          }() : function () {
            seq.propagating = 0;
            var core = seq.done === 0 ? function () {
              seq.valOnT = seq.evalEqs(tval); //self eqs eval
              seq.T = Date.now();
              var core1 = store ? function () {
                seq.IndexOnTimestamp[seq.T] = seq.length;
                seq.TimestampOnIndex[seq.length] = seq.T;
                seq[seq.length] = seq.valOnT; //after funcs
              }() : true;
              Object.keys(seq.updatedTo).map(function (key) {
                seq.updatedTo[key] = 1;
              });
              //clear updated us in non-interference way
              seq.us.map(function (u) {
                return u.updatedTo[seq.id] = 0;
              });
              seq.ds.map(function (d) {
                var usAllUpdated = d.us.map(function (u) {
                  return u.updatedTo[d.id];
                }).reduce(function (a, b) {
                  return a * b;
                });
                var core2 = usAllUpdated === 1 ? function () {
                  d.propagating = 1;
                  d.t = d.us.map(function (u) {
                    return u.t;
                  });
                }() : true;
              });
            }() : true;
          }();
        }
      }
    });
    return seq;
  }
228232
private void initializeApplication(ApplicationDefinition currAppDef, ApplicationDefinition appDef) {
        getStorageService(appDef).initializeApplication(currAppDef, appDef);
        storeApplicationSchema(appDef);
    }
733357
function (args) {
  if (false === (this instanceof Store)) throw new Error('new operator required');
  args = args || {};
  this.storeType = args.storeType || "Store";
  this.name = args.name || 'a ' + this.storeType;
  this.storeProperty = {
    isReady: false,
    canGetModel: false,
    canPutModel: false,
    canDeleteModel: false,
    canGetList: false
  };
  var unusedProperties = getInvalidProperties(args, ['name', 'storeType']);
  var errorList = [];
  for (var i = 0; i < unusedProperties.length; i++) errorList.push('invalid property: ' + unusedProperties[i]);
  if (errorList.length > 1) throw new Error('error creating Store: multiple errors');
  if (errorList.length) throw new Error('error creating Store: ' + errorList[0]);
}
245590
function setup() {
        $dataStore = new PersonalDataStoreStub();
        $this->eventStore = new TestEventStoreSpy();

        $this->container = new ContainerStub();
        $this->container->set(EventStore::class, $this->eventStore);

        $this->classMap  = new DomainEventClassMap();
        $this->commandBus = new ReflectionResolutionCommandBus($this->container);

        $this->serializer = new ReflectionBasedDomainEventSerializer(
            $this->classMap,
            new ValueSerializer($dataStore),
            $dataStore
        );
    }
400941
function createStore(descriptor) {
    var store = new pastore_1.XStore(descriptor.initState);
    store.name = descriptor.name;
    if (descriptor.actions)
        store.actions = descriptor.actions;
    if (descriptor.middlewares)
        store.actionMiddlewares = descriptor.middlewares;
    return store;
}
1043764
function(apiVers = "1.2", verb = true, storeT = "file", storeL = "results/") {
    __verifyVersion.call(this, apiVers);
    __verifyStore.call(this, storeT, storeL);

    this.apiVersion = apiVers;
    this.verbose = verb;
    this.storeType = storeT;
    this.storeLocation = storeL;

    // Instantiate an instance of the appropriate API depending on version
    if ( this.apiVersion == '1.0' ) {
        this.apiInstance = new API_v1_0(this.verbose, this.storeType,
        	this.storeLocation);
    }

    if ( this.apiVersion == '1.1' ) {
        this.apiInstance = new API_v1_1(this.verbose, this.storeType,
            this.storeLocation);
    }

    if ( this.apiVersion == '1.2' ) {
        this.apiInstance = new API_v1_2(this.verbose, this.storeType,
            this.storeLocation);
    }

    if ( this.apiVersion == '2.0' ) {
        this.apiInstance = new API_v2_0(this.verbose, this.storeType,
            this.storeLocation);
    }
}
753511
function CacheManager (options) {
  options = options || {};

  options.ttl = Number(options.ttl);
  if (isNaN(options.ttl)) options.ttl = DEFAULT_TTL;

  if (!options.store) {
    options.store = new MemoryStore();
  }
  if (typeof options.store === 'string') {
    options.store = getDefaultStore(options.store, options.storeConfig);
  }
  if (typeof options.store.get !== 'function') {
    throw new Error('store engine must implement `get` method');
  }
  if (typeof options.store.set !== 'function') {
    throw new Error('store engine must implement `set` method');
  }
  if (typeof options.store.delete !== 'function') {
    throw new Error('store engine must implement `delete` method');
  }

  debug('create: ttl=%s', options.ttl);
  this._ttl = options.ttl;
  this._store = options.store;

  this._keys = {};
  this._fuzzyKeys = [];

  this._getMethodQueue = new CallQueue();
}
563124
def get_data_store(args):
    """"""
    return tacl.DataStore(args.db, args.memory, args.ram)
41984
function setupBrowserStorage(){
    if(browser || storageMock){
      if(storageMock){
        store = storageMock;
        storageKey = 'cache-module-storage-mock';
      }
      else{
        var storageType = (config.storage === 'local' || config.storage === 'session') ? config.storage : null;
        store = (storageType && typeof Storage !== void(0)) ? window[storageType + 'Storage'] : false;
        storageKey = (storageType) ? self.type + '-' + storageType + '-storage' : null;
      }
      if(store){
        var db = store.getItem(storageKey);
        try {
          cache = JSON.parse(db) || cache;
        } catch (err) { /* Do nothing */ }
      }
      // If storageType is set but store is not, the desired storage mechanism was not available
      else if(storageType){
        log(true, 'Browser storage is not supported by this browser. Defaulting to an in-memory cache.');
      }
    }
  }
135214
def init(name, kind, args = {})
      get_storage(self.class.type, kind, name, args)
      true
    end