UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Afd7c0+9cmHeTORHzHeU37ZZSXwPtsjbjZ0mj5Gy8GM=' 
WHERE 
  key_id = 'bafe8a24a6d80037b5fdc841fb1d977a5d496991eed8a8ca7f447c56e66704a2' 
  AND (
    token = 'Afd7c0+9cmHeTORHzHeU37ZZSXwPtsjbjZ0mj5Gy8GM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00027