UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'AqJuuQM68XFAv42+vU209tdvAPAZXCGg0HEoTLafYpA=' 
WHERE 
  key_id = '851b34b4abcda7e31987420f2d197572850c34dc4125986cd3bf8b7dd7804992' 
  AND (
    token = 'AqJuuQM68XFAv42+vU209tdvAPAZXCGg0HEoTLafYpA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00044