UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'r9BoG9YYrJfaa19abluY8x1M73hhbo42W58qccl3G10=' 
WHERE 
  key_id = '346b1b842da491f94c14613af569888141a197089019f9a0aa7836c2e1b38766' 
  AND (
    token = 'r9BoG9YYrJfaa19abluY8x1M73hhbo42W58qccl3G10=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00044