UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'BrSP+ht+0UnEBH5F+wbKn8Tod6hvdmKq9tBN8D/S+/k=' 
WHERE 
  key_id = '970353b0781ce976d88bb7759c2eca305376bcde7ee57101b6e008d4af3c425b' 
  AND (
    token = 'BrSP+ht+0UnEBH5F+wbKn8Tod6hvdmKq9tBN8D/S+/k=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028