Commits

Kenneth Love committed 0622e13

adding strings and sets with TTLs works

  • Participants
  • Parent commits f34f74c

Comments (0)

Files changed (2)

     """
     key_name = TextField('Key', validators=[Required()])
     member = TextField('Member', validators=[Required()])
+    key_ttl = IntegerField('TTL')
 
 # Context processors
 @app.context_processor
     if form.validate_on_submit():
         key = request.form['key_name']
         value = request.form['key_value']
+        ttl = request.form['key_ttl']
 
         r = get_redis_connection(session)
         if not r:
 
         try:
             r.set(key, value)
+            if ttl and ttl != 0:
+                r.expire(key, ttl)
+
             flash('%s was saved successfully.' % key)
             return redirect('#%s' % key)
         except:
     if form.validate_on_submit():
         key = request.form['key_name']
         member = request.form['member']
+        ttl = request.form['key_ttl']
 
         r = get_redis_connection(session)
         if not r:
 
         result = r.sadd(key, member)
 
+        if ttl and ttl != 0:
+            r.expire(key, ttl)
+
         if result:
             flash('%s was created.' % key)
         else:

templates/new_set.html

 		{{ form.csrf }}
 		{{ render_field(form.key_name) }}
 		{{ render_field(form.member) }}
+		{{ render_field(form.key_ttl, type="number", class="optional") }}
 		<a href="{{ url_for('index') }}" id="cancel">cancel</a>
 		<input type="submit" value="Submit">
 	</form>