UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'dw5r6H9YmKSxFzc4x1AY0dpjjBEN6keBv3/lSTGCy54=' 
WHERE 
  key_id = '5064aff9e71cccea842443d7462af0f2b6606d4a1a082c52dda705fca98db171' 
  AND (
    token = 'dw5r6H9YmKSxFzc4x1AY0dpjjBEN6keBv3/lSTGCy54=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00051