MediaWiki REL1_33
APCBagOStuff.php
Go to the documentation of this file.
1<?php
36class APCBagOStuff extends BagOStuff {
42 const KEY_SUFFIX = ':3';
43
44 protected function doGet( $key, $flags = 0, &$casToken = null ) {
45 $casToken = null;
46
47 $blob = apc_fetch( $key . self::KEY_SUFFIX );
48 $value = $this->unserialize( $blob );
49 if ( $value !== false ) {
50 $casToken = $blob; // don't bother hashing this
51 }
52
53 return $value;
54 }
55
56 public function set( $key, $value, $exptime = 0, $flags = 0 ) {
57 apc_store(
58 $key . self::KEY_SUFFIX,
59 $this->serialize( $value ),
60 $exptime
61 );
62
63 return true;
64 }
65
66 public function add( $key, $value, $exptime = 0, $flags = 0 ) {
67 return apc_add(
68 $key . self::KEY_SUFFIX,
69 $this->serialize( $value ),
70 $exptime
71 );
72 }
73
74 public function delete( $key, $flags = 0 ) {
75 apc_delete( $key . self::KEY_SUFFIX );
76
77 return true;
78 }
79
80 public function incr( $key, $value = 1 ) {
81 return apc_inc( $key . self::KEY_SUFFIX, $value );
82 }
83
84 public function decr( $key, $value = 1 ) {
85 return apc_dec( $key . self::KEY_SUFFIX, $value );
86 }
87
88 protected function serialize( $value ) {
89 return $this->isInteger( $value ) ? (int)$value : serialize( $value );
90 }
91
92 protected function unserialize( $value ) {
93 return $this->isInteger( $value ) ? (int)$value : unserialize( $value );
94 }
95}
serialize()
This is a wrapper for APC's shared memory functions.
doGet( $key, $flags=0, &$casToken=null)
add( $key, $value, $exptime=0, $flags=0)
Insert an item if it does not already exist.
decr( $key, $value=1)
Decrease stored value of $key by $value while preserving its TTL.
serialize( $value)
unserialize( $value)
incr( $key, $value=1)
Increase stored value of $key by $value while preserving its TTL.
Class representing a cache/ephemeral data store.
Definition BagOStuff.php:58
isInteger( $value)
Check if a value is an integer.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37